Opening a Table

In contrast, when you open a table directly, you must supply the connection information at the beginning of each session to establish a connection to the data source. None of the information needed to establish a connection to the remote data source is stored in your Microsoft Jet database. To open a table directly, you must use the OpenDatabase method in Microsoft Access or VBA, and you must supply connection information (such as the data source, user name, password, and database name), as in the following example:

Dim dbs As Database
Dim tdf As TableDef
Dim fld As Field
Dim rst As Recordset

' Open FoxPro database.
Set dbs = OpenDatabase("C:\JetBook\Samples\FoxTables\Sales", False, _
	False, "FoxPro 3.0")
' Return a reference to FoxPro table.
Set tdf = dbs.TableDefs("EmpSales")
' Open a recordset on the table and 
' print the values in the Debug window.
Set rst = tdf.OpenRecordset
With rst
	Do Until .EOF
		For Each fld In .Fields
			Debug.Print "Name = " & fld.Name & " Value = " & fld.Value
		Next fld
		.MoveNext
	Loop
End With