Linking tables when changed dont display correct data

D

Don

I link to a "vendor" table.
Then I open a form and depending on a code field, the subform displays
data fronm the vendor table.
The subform shows the correct data.

In the form I select a different vendor table to link to.
The vba code deletes the link and establishes a link to the new table.
The displayed data is the same as the first linked table but when I
look at the table in my database the table is the new linked table.

DoCmd.DeleteObject acTable, "Employee"
DoCmd.TransferDatabase acLink, "Microsoft Access", VendorDBName &
".mdb", acTable, "Employee", "Employee", True


DoCmd.DeleteObject acTable, "Vendor"
DoCmd.TransferDatabase acLink, "Microsoft Access", VendorDBName &
".mdb", acTable, "Vendor", "Vendor", True

Does the "Form" keep all the links when it first opened and retains
them even if the vba code links to different table?

How can I release the old links while the form is still open?
 
D

David Lloyd

Don:

You may want to requery the form after you make the change to show the new
data.

For example:

Me.Requery


--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I link to a "vendor" table.
Then I open a form and depending on a code field, the subform displays
data fronm the vendor table.
The subform shows the correct data.

In the form I select a different vendor table to link to.
The vba code deletes the link and establishes a link to the new table.
The displayed data is the same as the first linked table but when I
look at the table in my database the table is the new linked table.

DoCmd.DeleteObject acTable, "Employee"
DoCmd.TransferDatabase acLink, "Microsoft Access", VendorDBName &
".mdb", acTable, "Employee", "Employee", True


DoCmd.DeleteObject acTable, "Vendor"
DoCmd.TransferDatabase acLink, "Microsoft Access", VendorDBName &
".mdb", acTable, "Vendor", "Vendor", True

Does the "Form" keep all the links when it first opened and retains
them even if the vba code links to different table?

How can I release the old links while the form is still open?
 
G

George Nicholson

Try
Me.Requery
where Me is the form you want updated with the "new" data.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top