Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

Linking Tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nigel Bennett - 09 Mar 2005 16:28 GMT
I have a table in the database that contains the names of
all the tables in my data base called zztables

Currently I have a docmd funtion that deletes the link to
each table and then after it has deleted the link it then
reattachs the table, this is hard coded in

I am looking for code where it will loop thru all the
records in zztable get each table name and then remove the
link and then loop thru the table again to reattach the
tables.

Hope this is enough info

Nigel
Sandra Daigle - 09 Mar 2005 16:45 GMT
Nigel,

Take a look at http://www.mvps.org/access/tables/tbl0009.htm for code to
relink tables. FWIW, you don't really have to keep a table of table names
since this information can easily be found in the tables collection.
Regardless, you should be able to adapt this code to your specific criteria.

Signature

Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

> I have a table in the database that contains the names of
> all the tables in my data base called zztables
[quoted text clipped - 11 lines]
>
> Nigel
Nigel Bennett - 09 Mar 2005 17:43 GMT
That works in one instance but what I am looking for is
code that looks at each record in the table and then adds
that to a variable carries out an action and then loops to
the next record and so on.
>-----Original Message-----
>Nigel,
[quoted text clipped - 21 lines]
>
>.
Sandra Daigle - 09 Mar 2005 18:44 GMT
Hi Nigel,

I'm not sure what you mean by "That works in one instance".  That code
actually does loop through a subset of the tables collection (the function
fGetLinkedTables() weeds out the ODBC connection tables). Regardless, here
is the basic code that demonstrates how you would loop through a recordset:

You can still use the code from fRefreshLinks as a guide for what you need
to do inside the loop. Basically you need the tablename and the path to the
linked database.

Open the recordset (once)
Test for records (EOF and BOF are both true when empty),
Loop through stopping when the EOF condition is reached.
   Inside the loop we do something with each record,
   Move to the next record
Close the recordset
Destroy the object variables.

Public Sub WalkRecordset()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
'tblMyTables is the name of your table
Set rst = db.OpenRecordset("Select * from tblMyTables")
With rst
   If Not (.EOF And .BOF) Then
       Do Until .EOF
           ' Here is the place to put the action you want to take on
           ' each record - use the code in  fRefreshLinks as a guide
           Debug.Print "TableName:" & .Fields("TableName")
           .MoveNext
       Loop
   End If
   .Close
End With
Set rst = Nothing
Set db = Nothing
End Sub

Signature

Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

> That works in one instance but what I am looking for is
> code that looks at each record in the table and then adds
[quoted text clipped - 31 lines]
>>
>> .
Nigel Bennett - 09 Mar 2005 21:05 GMT
THe problem I have is that i have a table called  address
and then another table called address1, they come from 2
different sources, so I need to make the code look in a
particular mdb for address and another mdb for the other
address table
>-----Original Message-----
>Hi Nigel,
[quoted text clipped - 74 lines]
>
>.
Sandra Daigle - 10 Mar 2005 13:37 GMT
The code will still work - just modify it to get the tablename and the path
to the backend database from your table.

Signature

Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

> THe problem I have is that i have a table called  address
> and then another table called address1, they come from 2
[quoted text clipped - 85 lines]
>>
>> .
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.