Insert into table with condition

V

V.P.

Hi all,

I have these tables:
tbl_Address: NameID(autonumber), FirstName, LastName, Address City, State, Zip
tbl_Category: CaID(autonumber), CaName
tbl_Sub: ScID(autonumber), ScName
tbl_X_Ref: NameID, CaID, ScID

I have an import form to import data (from different format)to a temp
tbl_Temp table, this work fine. Which mean now I have an tbl_Temp table
which vary in field names including Category column.
Ex: tbl_Temp
FN LN ADDRESS CITY ST ZIP ...
David Jones 123 test address San Francisco, Ca 23456 ...
CATEGORY SUBCATEGORY
Engineer VBA

I got all neccessary fields insert into tbl_Address nicely. Now I need to
insert into tbl_X_Ref values NameID, CaID, ScID for each record that depend
on Category in tbl_Temp and tbl_Category.
I know how to get the NameID (for both old LASTRECORD and new Last Record)
to do the loop. but I don't know how to get CaID if tbl_Temp.Category =
tbl_Categories.CategoryName (same as SubCategory). And if
tbl_Categories.CategoryName is not in the tbl_Category table I would like to
add it into tbl_Category.

Thanks in advance for your help...
VP
 

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

Top