G
Guest
Now that we've migrated the backend of the database to MySQL, I can't get the
current record ID after I do a AddNew code. I've tried the following two
methods but to no avail. I want to obtain the current record ID so that I
can add some other new data to 2 other tables related by the current record
ID. I've spent so much time on this!
Method 1:
Dim Rec As DAO.Recordset, curID As Long
Set Rec = db.OpenRecordset("CUSTOMER ACCESS", dbOpenDynaset)
With Rec
.AddNew
![UserName] = Me!txtUsername
.Update
Me![txtcurID] = curID
.Close
End With
Method 2:
Dim Rec As DAO.Recordset, curID As Long
Set Rec = db.OpenRecordset("CUSTOMER ACCESS", dbOpenDynaset)
With Rec
.AddNew
![UserName] = Me!txtUsername
.Update
strcriteria = "[USERNAME] = '" & Me!txtUsername & "'"
.FindFirst strcriteria
Me![txtcurID] = curID
.Close
End With
Has anyone tried this? Is there a better method?
current record ID after I do a AddNew code. I've tried the following two
methods but to no avail. I want to obtain the current record ID so that I
can add some other new data to 2 other tables related by the current record
ID. I've spent so much time on this!
Method 1:
Dim Rec As DAO.Recordset, curID As Long
Set Rec = db.OpenRecordset("CUSTOMER ACCESS", dbOpenDynaset)
With Rec
.AddNew
![UserName] = Me!txtUsername
.Update
Me![txtcurID] = curID
.Close
End With
Method 2:
Dim Rec As DAO.Recordset, curID As Long
Set Rec = db.OpenRecordset("CUSTOMER ACCESS", dbOpenDynaset)
With Rec
.AddNew
![UserName] = Me!txtUsername
.Update
strcriteria = "[USERNAME] = '" & Me!txtUsername & "'"
.FindFirst strcriteria
Me![txtcurID] = curID
.Close
End With
Has anyone tried this? Is there a better method?