copy table as many times as related fields ex-> name of copies same as related fields

zooz

New member
Local time
Today, 05:38
Joined
Apr 14, 2012
Messages
2
copy table as many times as related fields ex-> name of copies same as related fields

Hi everybody,


I have a question.

I have a table, which is called "x". That table is related to several fields in another table "y" , say the fields are called "1", "2" and "3".

Is there a VBA code, which asks for the desired table to choose, then creates exact copies of the table as many times as relations exist, BUT every copy of the table needs to have the exact name of the related field (in my example, just "1", "2" and "3".

Best would be, if the VBA code gives the possibility for multiple tables to choose, and then does the desired procedure with every table one after another.

I would be thankful for everybody who could help me out with some code, thanks!
 
Re: copy table as many times as related fields ex-> name of copies same as related fi

I must be missing something. Are you saying that if table y contains 50 records that are related to table x, you want to create 50 copies of table x each with only one record from table y?

Are you saying something different?

At any rate, if you're talking about using code to somehow make a bunch of duplicate copies of tables, each with only one (field? or record?), I'm struggling to imagine why in the world you would want to do anything even remotely close to that.
 
Re: copy table as many times as related fields ex-> name of copies same as related fi

Hi, I'm so sorry for being zoo ambiguous, I wasnt talking about relations exactly but about lookup tables.

I'll try another example:

The table "hobbies" serves as a lookup table for several fields in table "y", say "hobby1", "hobby2" and "hobby3".

now I would like to do 1:1 copies of table "hobbies", containing exactly all the same data, while the names of the copies are
"hobby1", "hobby2" and "hobby3".

Best would be if the VBA code asks me for a table to choose at the beginning for this procedure or severeal ones to repeat that procedure one after another.

Better don't ask why I need it like that, it's to prepare my data in a complicate way for another program.
Strange,but be sure it will save my day :)

If it is too complicated to write/ impossible to do, then please excuse me!
I'm quite inexperienced, and I just need it one time :)
 
Last edited:
Re: copy table as many times as related fields ex-> name of copies same as related fi

Just to clarify one more thing, is there:

a) a field in the hobbies table called something like "hobby" where the entered values are "hobby1", "hobby2" etc OR
b) a number of fields called "hobby 1", "hobby 2" etc
 
Re: copy table as many times as related fields ex-> name of copies same as related fi

I still don't have a clear idea of what it is you are attempting to do, but I do have two comments based on your last post.

First, your tables are improperly structured. The fact that you have repeating fields like Hobby1, Hobby2, Hobby3 is an indication of this fact. If this is an application that you plan to use regularly, you really should do some research on table normalization for relational databases.

Second, whatever it is you're trying to accomplish, if want separate to create separate record sets of Hobby1, Hobby2, etc., I strongly recommend you do so with queries and then export the query results to your external data program. I would never recommend that you create a bunch of duplicate tables containing sub sets of your original data.
 

Users who are viewing this thread

Back
Top Bottom