C
Chris
Hello group. I'm sure this is an easy question but I can't figure it out.
All I want to do is the following.
1) Insert a record into the master table
2) Get the value of the new PK (autonumber)
3) Add the value as a FK into a child table.
step 1 is not a problem, I've just written an insert Statement.
step 2 is the problem. I would normally use a DLookup statement to lookup
the value of the primart key (using the newly inputted values for 'Where
clause') However, in rare incidents, 2 records could be the same (e.g.
Client has 2 different cars with the same value ).
So my options are;
1) Order the table by the highest primary key value a then do the lookup,
don't know how to lookup this way
2) Bind the controls to the table ( don't like this appraoch as the I will
have to make the form bound)
3) Something else - think this is the best option.
Please advise me on the best method.
Tables
tblAssets ( AssetId (pk), ClientId(fk), AssetTypeId
tblvehicle (VehicleID (pk) AssetID(fk) Registration, make, model, value
tblproperty (propertyID (pk) AssetID (fk) Address, PostCode, Value
tblotherAsset (OtherAssetID(pk) AssetID(fk) AssetName, Value
All I want to do is the following.
1) Insert a record into the master table
2) Get the value of the new PK (autonumber)
3) Add the value as a FK into a child table.
step 1 is not a problem, I've just written an insert Statement.
step 2 is the problem. I would normally use a DLookup statement to lookup
the value of the primart key (using the newly inputted values for 'Where
clause') However, in rare incidents, 2 records could be the same (e.g.
Client has 2 different cars with the same value ).
So my options are;
1) Order the table by the highest primary key value a then do the lookup,
don't know how to lookup this way
2) Bind the controls to the table ( don't like this appraoch as the I will
have to make the form bound)
3) Something else - think this is the best option.
Please advise me on the best method.
Tables
tblAssets ( AssetId (pk), ClientId(fk), AssetTypeId
tblvehicle (VehicleID (pk) AssetID(fk) Registration, make, model, value
tblproperty (propertyID (pk) AssetID (fk) Address, PostCode, Value
tblotherAsset (OtherAssetID(pk) AssetID(fk) AssetName, Value