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

Giving users a Browse button to locate/renew linked tables... 1

Status
Not open for further replies.

petrosky

Technical User
Aug 1, 2001
512
AU
Hi,
I have this piece of code (contributed by one of you great people out there) which is quite handy for relinking tables in the Access frontend to the backend eg if it has moved.

I wonder if anyone has coded a way that when the function is called...the user can browse to the location of the backend db?

Here is the function as it stands now.

Function relinkTables(newPath)
Dim td As DAO.TableDef
For Each td In CurrentDb.TableDefs
On Error Resume Next
If (td.Attributes And dbAttachedTable) = dbAttachedTable Then
If LCase(td.Connect) <> LCase(&quot;;DATABASE=&quot; & newPath) Then
td.Connect = &quot;;DATABASE=&quot; & newPath
td.RefreshLink
End If
End If
On Error GoTo 0
Next
End Function

Any help is greatly appreciated.

Regards,

Peter Remember- It's nice to be important,
but it's important to be nice :)
 
You could place the CommonDialog on your form to search for the file. Pass the value to the code above.

The CommonDialog is a Reference which has to be added. You can do this from the Tools menu when using the VB Module Editor. The Access help covers the CommonDialog in detail.

Then use code like:

CommonDialog1.ShowOpen
If Len(CommonDialog1.FileName) = 0 Then
MsgBox &quot;No record Selected&quot;, vbInformation + vbOKOnly, &quot;Database Message&quot;
Else
Fname = CommonDialog1.FileName
Sandy
 
Many thanks for pointing me in the right direction


petrosky

Remember- It's nice to be important,
but it's important to be nice :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top