Link to home
Start Free TrialLog in
Avatar of jonesaj5
jonesaj5

asked on

Quick answer required

How do i get the primary key of the row i have just inserted in Access DB, Anyone know?

Thanks
AjONES.
Avatar of nico5038
nico5038
Flag of Netherlands image

If its an ascending key: DMAX("keyfieldname","table")

Nic;o)
Avatar of dgorin
dgorin

It sounds like you're referring to an Autonumber value.

The key value should be available in the recordset for your form, control, etc. after the data is inserted.

If you're using VBA code try checking the keyfield value in an after_update event procedure.
ASKER CERTIFIED SOLUTION
Avatar of cjswimmer
cjswimmer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using ADO and a client-side cursor then you might need to do a Recordset.Requery to get the id values.
////////////////////////////////////
Easy Tracking
////////////////////////////////////

Assume that you are doing a VB Application connected to an Access 2000 Database, provided you are having your primary key of the table set to 'Auto Number'

try

Adodc1.recordset.movelast
PryKey=.fields("PriKeyFieldName")+1


Hope it helps.

Cheers.

any update jonesaj5?
hello?