I have a (DAO) QueryDef and RecordSet set up with standard code.
Everything works fine up to here. The next line breaks VBA:
The error is Runtime Error 3420: Object invalid or no longer set.
I hit debug on the msg box, and when I hover over the rst.BOF and rst.EOF in the VBA IDE, I see a tooltip telling me rst.BOF is false (as is .EOF), so the object definitely exists. Yet when i hover over the rst.MoveFirst there is no tooltip.
How does the object become invalid? Does it lose scope as it enters the if branch? Or have I done something stupid
please help, it's driving me crazy
Code:
Set qdf = CurrentDb.CreateQueryDef("", sqlGetSurname)
qdf.Parameters(0) = candidateID
Set rst = qdf.OpenRecordset
'check we have only one row
If Not (rst.BOF And rst.EOF) Then
Code:
rst.MoveFirst
I hit debug on the msg box, and when I hover over the rst.BOF and rst.EOF in the VBA IDE, I see a tooltip telling me rst.BOF is false (as is .EOF), so the object definitely exists. Yet when i hover over the rst.MoveFirst there is no tooltip.
How does the object become invalid? Does it lose scope as it enters the if branch? Or have I done something stupid
please help, it's driving me crazy