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

"User Defined" error in Relinking Code

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
0
0
US
I was trying a Relinking Code I found in one of the FAQ links. I get an error "User Defined Type not Defined" (at Dim Dbs As Database) I am in a Access 2002 file and the code is:

'RelinkTables...Just as the name suggests pass a path to a database to this sub
'eg RelinkTables("c:\windows\test.mdb") and it will go through all the tables in your
'database and link them to the new location
'Written by John Hawkins 20/9/99 Public Sub RelinkTables(NewPathname As String)
Dim Dbs As Database (ERROR HERE)
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs


For Each Tdf In Tdfs 'Loop through the tables collection
If Tdf.SourceTableName <> &quot;&quot; Then 'If the table source is other than a base table
Tdf.Connect = &quot;;DATABASE=&quot; & NewPathname 'Set the new source
Tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table
End Sub
 
You are using ADO as a default in your reference list rather than DAO. Click on any form in design view. Click on view, click on code. From the VB editor, click on tools then references. Then add MS DAO reference. Then, in your code, change

dim db as database to

dim db as DAO.database. Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Thank you. That was it. Unfortunately, I can't see how to use that module to any effect. I am having a hard time figuring out an easy way for users to backup their backend and then restore it after a reinstall of both the front end and backend.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top