Here is my table design:
tblEmployers
EmployerID autonum (primary key)
EmployerName text
tblLocations
LocationID autonum (primary key)
EmployerID longint (foreign key)
LocationAdress text
LocationCity text
Location ...
...
...
what i am trying to do is have a form where you can enter a new
location, and when you type in the employer name it will either look up
the EmployerID in the tblEmployers table and insert it into the
tblLocations table, or if it doesn't exist, create a new entry in the
tblEmployers Table and insert the new EmployerID into the tblLocations
table. I am not sure exactly how to do this... right now i have a
query that just includes all fields from both tables, and a form based
on that query. in the tblLocations.Em ployerID field i have the control
source set to tblLocations_Em ployerID and the row source set to
tblEmployers.Em ployerID. this allows me to enter a new employer,
putting the right data in both tables EmployerID, but it will create a
new entry in the tblEmployers table even if the EmployerName already
exists.
Am i on the right track, or is there a better way to do this?
tblEmployers
EmployerID autonum (primary key)
EmployerName text
tblLocations
LocationID autonum (primary key)
EmployerID longint (foreign key)
LocationAdress text
LocationCity text
Location ...
...
...
what i am trying to do is have a form where you can enter a new
location, and when you type in the employer name it will either look up
the EmployerID in the tblEmployers table and insert it into the
tblLocations table, or if it doesn't exist, create a new entry in the
tblEmployers Table and insert the new EmployerID into the tblLocations
table. I am not sure exactly how to do this... right now i have a
query that just includes all fields from both tables, and a form based
on that query. in the tblLocations.Em ployerID field i have the control
source set to tblLocations_Em ployerID and the row source set to
tblEmployers.Em ployerID. this allows me to enter a new employer,
putting the right data in both tables EmployerID, but it will create a
new entry in the tblEmployers table even if the EmployerName already
exists.
Am i on the right track, or is there a better way to do this?
Comment