Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2005, 08:35 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replace and existing table with an updated one

I have a very small table (tbl_emp_lcl) that is stored on the client's side of a split database scenario (other tables are stored on server and linked to the client front end). I've written code to check the modified date of the same table stored on the server (tbl_emp_svr). If the date modified is more recent than the tbl_emp_lcl, then I change the table name of the local table to OLD_tbl_emp_lcl and import the more recent version from the server. My only problem is that after import, I want to delete the OLD table, but get an error saying "Can't delete the table until its relationships to other tables have been deleted."

How can I accomplish this using VB code so that the client/user doesn't see this message, but the old table still gets deleted? I want to be able to delete the existing relationships with the OLD table, and then delete the OLD table.

Also, is there a way to restore those relationships with the NEWLY IMPORTED table?

Thank you!!

Rick
__________________
Rick
 
Old August 29th, 2005, 10:13 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Why don't you just delete all the existing data and insert the new data rather than rename the table and create a new table and then delete the old table? The relationships become a non-issue using this method.

mmcdonal
 
Old August 29th, 2005, 10:14 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Actually, rather than check a date, you could just replace all the data each time the user opens the database. This should only take a second if this is a small table.

mmcdonal
 
Old August 29th, 2005, 10:36 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This sounds like a good idea. Can you give me an example of how this is done? Am I to open a recordset and then delete it? Sorry, I'm a bit confused as to how to delete the data and replace it without affecting the table.

Thank you for your help!!

Rick
 
Old August 29th, 2005, 02:06 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Well, you could make a delete query that deletes all the data in the table, then run that query when opening the database.
Then haul in a recordset from the back end and populate the table from that recordset.
How much more help do you need? If more, please give me the table structure of the small table.


mmcdonal
 
Old August 29th, 2005, 02:08 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, I didn't subscribe to this thread. I am submitting this to subscribe.

mmcdonal
 
Old August 30th, 2005, 07:44 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It worked perfectly.
Thank you very much. :)

Rick




Similar Threads
Thread Thread Starter Forum Replies Last Post
Find difference between table and updated table jasemhi Access 2 September 20th, 2008 04:25 PM
Creating table with existing table without value kumar_kumar Oracle 1 January 4th, 2005 07:12 AM
insert value of variable into an existing table mountaindew7612 SQL Server 2000 5 October 16th, 2004 12:48 PM
select into non-temp table? (existing) nlicata SQL Server 2000 3 November 7th, 2003 03:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.