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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top