Results 1 to 3 of 3

Thread: Populate field number data type

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Populate field number data type

    I am don't know how to populate the field name number data type. Code I have below populate all field name into combo box2

    Code:
    Public cnnACC As ADODB.Connection 'Access Connection
    Public rst As ADODB.RecordSet
    Dim adoField As ADODB.Field
    Public adoCat As ADOX.Catalog 'Catalog
    Public adoTbl As ADOX.Table 'Table
     Set rst = New ADODB.RecordSet
        'Set New connection
        Set cnnACC = New ADODB.Connection
        If rst.State = adStateOpen Then
            rst.Close
        End If
        
        
        
        Dim strDB, strConn As String
        strDB = TextBox1.Text
         'String Connection with Database path String
          strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDB & ";Persist Security Info=False"
         ' Open the connection
        cnnACC.Open strConn
      
       Dim sSQL As String
       vsRecordSource = ComboBox1.Text
       sSQL = "SELECT * FROM [" & vsRecordSource & " ]"
       rst.Open sSQL, cnnACC, adOpenDynamic, adLockOptimistic
    
         ComboBox2.Clear
         For Each adoField In rst.Fields
          ComboBox2.AddItem adoField.Name
          If ComboBox2.ListCount > 1 Then ComboBox2.ListIndex = 0
         Next

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: Populate field number data type

    Code:
    sSQL = "SELECT * FROM [" & vsRecordSource & " ]"
    Should be

    Code:
     sSQL = "SELECT [ColumnNameYouWant] FROM [" & vsRecordSource & " ]"
    PS: * means all column
    __________________
    Rate the posts that helped you

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Populate field number data type

    Ok I got it.. Anything I miss? I am trying to populate the combo box with all number field data type


    Code:
     ComboBox2.Clear
         For Each adoField In rst.Fields
          If adoField.Type = adNumeric Or adoField.Type = adDecimal Or adoField.Type = adSmallInt Or adoField.Type = adDouble Or adoField.Type = adInteger Or adoField.Type = adSingle Then
          ComboBox2.AddItem adoField.Name
          End If
         
         Next
         If ComboBox2.ListCount > 1 Then ComboBox2.ListIndex = 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width