Relationship setup with code?

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
I have a table (table 1) that is created via import text specs...this has 2 key fields which is set up via relationships to another table (table2)...what i want to do is replace table 1 each time i run the import and retain the relationship to table 2...but since i have relationships b/t the tables it won't do it properly...any ideas? how bout is there a way to code the relationship setup...what i'm thinking is i could create code to do the following things:
1) delete the relationship b/t the 2 files
2) delete table 1
3) import via text specs to table 1
4) reestablish the relationships

any ideas how to do this or do it another better way?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Why not import into an existing table which already has the relationship set up?
 
Upvote 0
that's what i was trying to do initially but it kept giving me 0 records updated...what i tried and seems to be working is i put a sql in the macro b/f the import that does the following.....delete * from extract....so essentially i'm deleting all the records from the table...then importing the new data into the existing structure of the table (with the relationships and everything set up)...sound like the right thing???
 
Upvote 0
Sounds right, does it actually work?
 
Upvote 0
it appears to in my initial tests...i'll have to keep hammering on it to make sure it won't break...thanks for your ideas...i appreciate it...
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,254
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top