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




Reply With Quote