importing related tables

M

Mario Krsnic

Hello everybody,
I have two related tables:
1) Tbl_categories with fields category(Text), id (Counter and primary key),
UserID (long)
2) Problems with fields Problem (Text), id (Long), UserID (long)
the field id form the second table in in relation 1:n with the primary key
id from the first table.
Every neuer User should get all records from this two tables so that all
records get his UserID.

I tried so:
insert into Tbl_categories (category, userID) select " & _
" category," & NewUserID & " from Tbl_categories where userID=" & 0
So I get the categories with the new UserID. But how to import the related
recordsets from the second table?
Thank you!
Mario
 
L

Lord Kelvan

run a second query

insert into Tbl_Users (userid,otherfields) "select " & NewUserID &
otherfields " from Tbl_users where userID=" & newuserid

or something like that

Regards
Kelvan
 
M

Mario Krsnic

Hello Kelvan,
run a second query

insert into Tbl_Users (userid,otherfields) "select " & NewUserID &
otherfields " from Tbl_users where userID=" & newuserid
There is no recordsets in this query:

"select " & NewUserID &
otherfields " from Tbl_users where userID=" & newuserid"

and so nothing can be imported! The newuserid is to be imported and cannot
therefore be a condition for the query!

After inserting categories in Tbl_categories there are old categories with
the newUserID and new ID (id is Counter-Field).
I need now the old records in the table "problems" with new UserID and ID
(id is in the relation with id from the tblCategories).
Lets take a example:
All recordsets have at the very beginning UserID 0.
TblCategories:
FieldCategory ID UserID
Mobility 1 0
Alimentation 2 0

TblProblems
Cannot walk 1 0
Cannot eat alone 2 0

After importing categories for the new user we have:
FieldCategory ID UserID
Mobility 1 0
Alimentation 2 0
Mobility 3 1
Alimentation 4 1
Now I would like to import the recordsets from the table problems with
UserID=0 in the same table, so that they get UserID=1 and ID 3 or 4.
Thanks
Mario
 
L

Lord Kelvan

if you want to know how old a record is add a time stamp to every
inserted record using now()

create a field in the table and set the default value to be =now() and
it will add a time stamp

Regards
Kelvan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top