A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Temporarily disable relationships/constraints



 
 
Thread Tools Display Modes
  #1  
Old November 26th, 2009, 04:26 PM posted to microsoft.public.access.queries
Ben8765
external usenet poster
 
Posts: 11
Default Temporarily disable relationships/constraints

Hi,

I am trying to do append queries from many tables in database 'A' to tables
in database 'B' through vba code.

The problem is that there are relationships/constraints on the tables. I
could write code to make the tables append in the correct order so that the
'One' in 'One-to-many' would exist before the 'Many'. But this would require
a lot of hard coding, which is not practical.

Is there a way to temporarily turn off the relationships/constraints?

According to this website, you can do this sort of thing in SQL Server:

ALTER TABLE foo WITH NOCHECK CONSTRAINT ALL
http://stackoverflow.com/questions/7...ts-temporarily

Is this possible in access? Or is there something else I should be doing?

-Ben

  #2  
Old November 26th, 2009, 05:26 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Temporarily disable relationships/constraints

As far as I know, it is NOT possible to do this in Access. You need to do the
appends in order.

You could write VBA code to remove all the relationships and then
restore/rebuild them after the update is finished. Of course, the danger is
that if you did add a record or records that did not comply with the
relationship rule, you would generate an error when you tried to rebuild the
relationship.



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Ben8765 wrote:
Hi,

I am trying to do append queries from many tables in database 'A' to tables
in database 'B' through vba code.

The problem is that there are relationships/constraints on the tables. I
could write code to make the tables append in the correct order so that the
'One' in 'One-to-many' would exist before the 'Many'. But this would require
a lot of hard coding, which is not practical.

Is there a way to temporarily turn off the relationships/constraints?

According to this website, you can do this sort of thing in SQL Server:

ALTER TABLE foo WITH NOCHECK CONSTRAINT ALL
http://stackoverflow.com/questions/7...ts-temporarily

Is this possible in access? Or is there something else I should be doing?

-Ben

 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.