DLookup doesn' always find value of new record

H

Helen Trim

The key value is available for reading as soon as you have
created the new record, so you can just read it before
doing the update.

I tried this in Northwind and it worked:

Sub Test()
Dim Db As Database
Dim Rs As Recordset

Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Products")

Rs.AddNew
Rs("ProductName") = "New Product"
MsgBox Rs("ProductId")
Rs.Update

End Sub

Hope this helps,
Helen
 
Top