This is from swilliams' post for another question; it should help:
swilliams (Programmer) Oct 5, 2000
... This post was intended to explain how to fill a combo box from a db field ...
Private Sub Fill_Combo(cboBox As ComboBox, ByVal sTable As String, ByVal sDisplayField As String)
Dim db As Database
Dim rs As Recordset
Set db = Workspaces(0).OpenDatabase("c:\aa\newdata.mdb", False, False)
Set rs = db.OpenRecordset("SELECT DISTINCT " & sDisplayField & " FROM " & sTable & " ORDER BY " &
sDisplayField, dbOpenSnapshot)
cboBox.Clear
Do Until rs.EOF
cboBox.AddItem rs(sDisplayField)
rs.MoveNext
Loop
rs.Close
Set db = Nothing
This is swilliams (Simon):
To access a field in a dbf file, in Access link to the dbf file and then it can be treated just like an Access table (so that you can use the previously posted code)
Simon,
I'm a begginner in VB. What do you want to say with "Access link to the dbf". May you explain to me, please, with a sample.
Thanks.
CCortez [sig][/sig]
When you are in Access, on the table view, click on New to create a new table. Select Link table from the list and then you will see a windows dialogue box. Change the file types viewed (in one of the combo boxes) to select FoxPro tables (*.dbf) and then navigate to the dbf file you want to look at.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.