Save type info to form : Type « Data Type « VBA / Excel / Access / Word






Save type info to form

 
Type CompanyInfo
    SetUpID As Long
    CompanyName As String * 50
    Address As String * 255
    City As String * 50
    StateProvince As String * 20
    PostalCode As String * 20
    Country As String * 50
    PhoneNumber As String * 30
    FaxNumber As String * 30
    DefaultPaymentTerms As String * 255
    DefaultInvoiceDescription As String
End Type

Public typCompanyInfo As CompanyInfo
Sub PopulateControls()
    txtCompanyName.Value = Trim(typCompanyInfo.CompanyName)
    txtAddress.Value = Trim(typCompanyInfo.Address)
    txtCityStateZip.Value = Trim(typCompanyInfo.City) & ", " & _
        Trim(typCompanyInfo.StateProvince) & _
        "  " & Format(Trim(typCompanyInfo.PostalCode), "!&&&&&-&&&&")
    txtPhoneFax.Value = "PHONE: " & _
        Format(Trim(typCompanyInfo.PhoneNumber), "(&&&)&&&-&&&&") & _
        "       FAX: " & _
        Format(Trim(typCompanyInfo.FaxNumber), "(&&&)&&&-&&&&")
End Sub

 








Related examples in the same category

1.An Example of Using a Type Structure
2.Create a new data type
3.User-Defined Data Types