Reputation: 5339
I have a multiple items form which does not mention the ID of the record. I have a button for each row which, when clicked, opens up a new form containing more details.
In the past, I've added a field for the ID but made it invisible, but this seems silly - the ID is a unique field of the original query, so I should be able to access purely with code somehow.
Does anybody know how to do this? Let me know if you want more clarification.
Update
The fastest way for me to do this is to add a field in the form for the field in the query, call it the query field name, save it all and close it, then delete the field. Though of course I'd rather just be able to do Me.ID without any of that prior nonsense.
Upvotes: 1
Views: 2157
Reputation: 91306
In some cases, you may have to refer to Me!ID, rather than Me.ID because the field has not been added as a property of the form (discussion: http://tek-tips.com/viewthread.cfm?qid=1127364 )
When you add the ID as as control and then delete it, it becomes a property of the form, which is why your work-around works.
Upvotes: 1
Reputation: 97101
If a form's record source includes a field named "ID", you can access the field's value as a property of the form:
Debug.Print Me.ID
That works without a control bound to the field.
Upvotes: 1
Reputation: 588
you probably need to edit the recordsource / query.. and add that column as an available field.
Upvotes: 0