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!

Link Table Problem

Status
Not open for further replies.

NewfieGolfer

Technical User
Mar 29, 2001
80
CA
Hello All,

I have a database (main database) that creates two other databases. The main database has all the tables, querys,forms, and reports. The forms, querys, and reports are copied to database 1, and the tables are copied to database 2. I was wondering how to make link tables in database 1 that are linked to the tables in database 2. This needs to be done via the main database in Visual Basic.

Any Help Appreciated,
NG
 
wait... The Import/Link wizard won't work for your table linkings?

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Josh,
I need to do the links using visual basic when the user presses a button on a form. All table setups and connections must be done using VBA. It has to be done in a way that the user never has to manually set up the links. BTW, this process can be performed many times, that is, whenever the user hits a button on a form. I have no problem setting up link tables from my main database to another database, but the problem occurs when i try to use a database to set up link tables in a second database using tables from a third database.

NG
 
Hrmm...
>I have no problem setting up link tables from my main >database to another database, but the problem occurs when >i try to use a database to set up link tables in a second >database using tables from a third database.

So you are trying to Place Linked Tables in datbase 3 from database 2 ... but databse 2's tables (the ones supposed to o in db 3) are linked from DB 1? .. Why not just link DB 3 back to DB 1 and skip DB 2? .. Also....

Could you use recordsets?

Ie:

Dim DB1 as Database
Dim RS1 as Recordset
Set DB1 = "C:\MyPath\MyDB.MDB"
Set RS1 = DB1.OpenRecordset("tblLinkedTable")

With RS1
RS1.Edit
RS1![Fieldname] = txtbox1 'or your can do "text" or you can set it euqal to a string you setup, wahtever u want.
'RS1![TimeSent] = VBA.Time
RS1.Update

You can also do .AddNew to recordsets, etc. Pretty much whatever you want. .FindFirst, .AddNew, .Edit, .MoveFirst, .MoveLast, etc... read up on them..

Or if you are just trying to use the linked tables as your control source you could probably manipulate this too. Just an idea.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
"So you are trying to Place Linked Tables in datbase 3 from database 2 ... but databse 2's tables (the ones supposed to o in db 3) are linked from DB 1? .. Why not just link DB 3 back to DB 1 and skip DB 2? .. Also...."

Db 2's tables are not linked from db 1. They are copied from database 1. The tables in database 2 are goin to be placed on a network as a back end, and the link tables in database 3 will be used with the front end. This setup needs to be done with database 1.

NG
 
I figure this out. Here's the code to use, FYI. This code is in the form in the main database. File1 is database 1, and File2 is database 2:

file1 = "c:\Link Table Database.mdb"
file2 = "c:\Copied Tables Database.mdb"
Set mydb = OpenDatabase(file2)
Set tdf = mydb.CreateTableDef("Link Table")
tdf.Connect = ";DATABASE=" & file1
tdf.SourceTableName = "Copied Table"
mydb.TableDefs.Append tdf
RefreshDatabaseWindow


Thanks,
NG
 
NG,
SOrry I didn't reply. I'm glad that you got it fig'd out. I was out of town over the past 4 days - moving apartments up at school. I'm Back at work now, though - and ready to answer questions.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top