An Example of Using a Type Structure : Type « Data Type « VBA / Excel / Access / Word






An Example of Using a Type Structure

 
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 GetCompanyInfo()

    Dim strSubName As String
    Dim rst As ADODB.Recordset

    Set rst = New ADODB.Recordset
    rst.ActiveConnection = CurrentProject.Connection
    rst.Open "Select * from CompanyInfo", Options:=adCmdText

    With typCompanyInfo
        .SetUpID = rst!SetUpID
        .CompanyName = rst!CompanyName
        .Address = rst!Address
        .City = rst!City
        .StateProvince = rst!StateOrProvince
        .PostalCode = rst!PostalCode
        .Country = rst!Country
        .PhoneNumber = rst!PhoneNumber
        .FaxNumber = rst!PhoneNumber
    End With

    rst.Close
    Set rst = Nothing
End Sub

 








Related examples in the same category

1.Save type info to form
2.Create a new data type
3.User-Defined Data Types