Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing data in DBF files 1

Status
Not open for further replies.

CCortez

Programmer
Sep 18, 2000
16
BR
Somebody may help me with a sample code to access a field in a dbf file, using VB6 ?
Thank you.
[sig][/sig]
 
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

End Sub

And then call the subroutine by having the line:

Fill_Combo Combo1, "TableName", "FieldName"



Hope this helps.
Robert [sig][/sig]
 
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 [sig][/sig]
 
Thanks for all, guys.

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.

Simon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top