Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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
Reply With Quote
  #6 (permalink)  
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
Reply With Quote
  #7 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:14 PM.


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