N
News Boy
I'd like to create a database to keep track of which routes go with which
carriers, and which substitute carriers are associated with them.
A carrier can have more than one route, but a route can have only one
carrier, and they change occasionally to frequently.
After a lot of trial and error, I have designed a simple database to test
Access' behavior. Forgetting the substitutes for the moment, I have
constructed 2 tables:
tblRoutes
ID (AutoNum), primary key
Route (Integer)
Carrier (Long Integer)
tblCarriers
ID (AutoNum)
LastName (String)
Account# (Long Integer), primary key
Carriers.Account# is related one-to-many to Routes.Carrier with referential
integrity and cascade update and cascade delete enabled, and tblRoutes will
naturally have more records than tblCarriers.
I'm trying to add records to the tables via a form with a query as the data
source:
SELECT Routes.ID AS Routes_ID, Routes.Route, Routes.Carrier, Carriers.ID AS
Carriers_ID, Carriers.LastName, Carriers.[Account Number]
FROM Routes RIGHT JOIN Carriers ON Routes.Carrier=Carriers.[Account Number]
ORDER BY Routes.Route;
This was built in the Access Wizard, as I am not familiar with SQL, yet, and
I've never used Access before and the help files are not very instructional
for design view.
If I try to enter a record for a route associated with a carrier already in
the table, I can type in the Routes.Carrier field and Access will
automatically fill in Carrier.LastName and Carrier.Account# boxes. But, if I
try to enter a new route with a carrier not yet in the table via the
Routes.Carrier field, I get the following error:
The Microsoft Jet database engine cannot find a record in the table
'Carriers' with the key matching field(s) 'carrier'.
.. . . meaning I need to enter the Carrier.Account# first. But, if I try to
enter a record via the Carrier.Account# field, and that carrier already
exists, I get an error message about not allowing duplicates in primary keys.
So, I need to have a single text box on the data entry form that can sense
which field to access: Routes.Carrier when the carrier already exists, and
Carrier.Account# when the carrier does not yet exist.
Is this accomplished via the query, or some switch in the form properties,
or how?
thank you for your help.
carriers, and which substitute carriers are associated with them.
A carrier can have more than one route, but a route can have only one
carrier, and they change occasionally to frequently.
After a lot of trial and error, I have designed a simple database to test
Access' behavior. Forgetting the substitutes for the moment, I have
constructed 2 tables:
tblRoutes
ID (AutoNum), primary key
Route (Integer)
Carrier (Long Integer)
tblCarriers
ID (AutoNum)
LastName (String)
Account# (Long Integer), primary key
Carriers.Account# is related one-to-many to Routes.Carrier with referential
integrity and cascade update and cascade delete enabled, and tblRoutes will
naturally have more records than tblCarriers.
I'm trying to add records to the tables via a form with a query as the data
source:
SELECT Routes.ID AS Routes_ID, Routes.Route, Routes.Carrier, Carriers.ID AS
Carriers_ID, Carriers.LastName, Carriers.[Account Number]
FROM Routes RIGHT JOIN Carriers ON Routes.Carrier=Carriers.[Account Number]
ORDER BY Routes.Route;
This was built in the Access Wizard, as I am not familiar with SQL, yet, and
I've never used Access before and the help files are not very instructional
for design view.
If I try to enter a record for a route associated with a carrier already in
the table, I can type in the Routes.Carrier field and Access will
automatically fill in Carrier.LastName and Carrier.Account# boxes. But, if I
try to enter a new route with a carrier not yet in the table via the
Routes.Carrier field, I get the following error:
The Microsoft Jet database engine cannot find a record in the table
'Carriers' with the key matching field(s) 'carrier'.
.. . . meaning I need to enter the Carrier.Account# first. But, if I try to
enter a record via the Carrier.Account# field, and that carrier already
exists, I get an error message about not allowing duplicates in primary keys.
So, I need to have a single text box on the data entry form that can sense
which field to access: Routes.Carrier when the carrier already exists, and
Carrier.Account# when the carrier does not yet exist.
Is this accomplished via the query, or some switch in the form properties,
or how?
thank you for your help.