Reputation: 31
Okay I am working with Access 2021, VBA programming ist more than a decade ago so I need some basic help.
I'm having
if I double-click on a list item, Me.lstItems.Value gives me the actual ID of the record, not the record number. Now I want the underlying form (frmMyForm) to go to the recordset with this ID.
frmMyForm.FindFirst "[ID] LIKE 'Me.lstItems.Value'"
(which throws me an error, [variable not defined])
or something like
DoCmd.GoToRecord acDataForm, "frmMyForm", acGoTo, Me.lstItems.ID
(which throws me an error, [method or variable not defined])
I tried any combination of the above objects, but cannot reside.
Upvotes: 0
Views: 129
Reputation: 112632
If your ID is numeric:
Me.Recordset.FindFirst "[ID] = " & Me.lstItems.Value ' E.g. "[ID] = 7"
If it is a text:
Me.Recordset.FindFirst "[ID] = '" & Me.lstItems.Value & "'" ' E.g. "[ID] = 'abc'"
Upvotes: 1