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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking DBF using code

Status
Not open for further replies.

krill

Programmer
Jan 16, 2001
38
AU
Can somebody please help me out !

I have external dbf files. I need to create via vb code a actual link between Access97 and the dBAse 5 file..I have code to create links betwween access tables from external databases but I'm struck on dbf files..

If you have a cure can you post some example code.

Thanks heaps!!

gerard
 
I can provide a semi solution. What I had to do was link the DBF files using the usual link process in Access. Unfortunately, from time to time the links would go across the sky with Peter Pan to Never Never land. The following function will relink them.

You might be able to use the code to actually build the links for you. Good luck.


'===========================================================
Const conConnectPrefix = "dBase III;HDR=NO;IMEX=2;DATABASE="
'===========================================================

Sub LinkDBFs()

Dim strConnect As String
Dim strNewConnect As String
Dim strPath As String
Dim strFileName As String
Dim I As Integer
Dim x As Integer
Dim y As Integer
Dim Bfdb As Database
Dim tdf As TableDef

Set Bfdb = CurrentDb()
For Each tdf In Bfdb.TableDefs
If Left(tdf.Name, 3) = "DBF" Then
x = 0
y = 0

strPath = Left(CurrentDb().Name, Len(CurrentDb().Name) - 15)

'recreate connect string
strNewConnect = conConnectPrefix & strPath
tdf.Connect = strNewConnect
tdf.RefreshLink
End If
Next tdf

Set tdf = Nothing
Set Bfdb = Nothing

End Sub

Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top