0

I run a VBA function from an "After Update" data macro via SetLocalVar. This VBA function queries the row that was just updated (taking the table name and a unique ID to select). However, the row that I get is the pre-update row.

So it is as if my function runs before the update, even though it is an "After Update" data macro.

Why is the row not updated by the time my VBA function selects it?

Here is my query:

Dim rs As Recordset
Set rs = MyDB.OpenRecordset("SELECT * FROM " & table & " WHERE " & primaryKey & " = " & primaryId, dbOpenSnapshot)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
jccc
  • 41
  • 2
  • 1
    Please post the function in question, or at least the relevant snippets. – Klaycon Nov 18 '19 at 21:21
  • `Dim rs As Recordset Set rs = MyDB.OpenRecordset("SELECT * FROM " & table & " WHERE " & primaryKey & " = " & primaryId, dbOpenSnapshot)` The macro, VBA call, and query all work. However, the fields I get are the pre-update fields. (I can't seem to format this code any better; sorry. Should be two lines.) – jccc Nov 18 '19 at 21:26
  • Just to check, what's your function header look like? – Klaycon Nov 18 '19 at 21:28
  • Not sure what you mean by header. Do you mean this? `Public Function addToCache(op, table, primaryKey, primaryId)` Again, I'm getting the right row back from the query. It's just the old field values from before the update. – jccc Nov 18 '19 at 21:29

0 Answers0