Hi,
I'm doing an INSERT into a Access Jet table in a VB 6.0 program and I need the AutoNumber value from the record just inserted so I can later do an update. This will be a MultiUser environment so I don't want to just read the last record I just inserted in case someone else inserted one after the one I just inserted and I then get the wrong one.
Is there a way to get the AutoNumber for the record I just inserted into a table without reading the last record? Here is my code.
Dim sQuery As string
sQuery = "INSERT INTO tblLogon " _
& "(strLogonId, LogonTime)" _
& VALUES('" & txtLogonId & "'," _
& "'" & Now() & "')"
cn.Execute sQuery
I also have the following 2 fields in the table and I want to update the LogOffTime field later but I don't want to wait and just do the Insert at the end so I will have to do an update.
lngAutoId - the autonumber
LogOffTime - another field
I also need to capture the lngAutoId value after the insert so I can later use it's value as a foreign key for an insert into another table.
Does anyone know how to get the AutoNumber after an insert?
Thanks,
Austral
I'm doing an INSERT into a Access Jet table in a VB 6.0 program and I need the AutoNumber value from the record just inserted so I can later do an update. This will be a MultiUser environment so I don't want to just read the last record I just inserted in case someone else inserted one after the one I just inserted and I then get the wrong one.
Is there a way to get the AutoNumber for the record I just inserted into a table without reading the last record? Here is my code.
Dim sQuery As string
sQuery = "INSERT INTO tblLogon " _
& "(strLogonId, LogonTime)" _
& VALUES('" & txtLogonId & "'," _
& "'" & Now() & "')"
cn.Execute sQuery
I also have the following 2 fields in the table and I want to update the LogOffTime field later but I don't want to wait and just do the Insert at the end so I will have to do an update.
lngAutoId - the autonumber
LogOffTime - another field
I also need to capture the lngAutoId value after the insert so I can later use it's value as a foreign key for an insert into another table.
Does anyone know how to get the AutoNumber after an insert?
Thanks,
Austral