ms-accessms-access-2007vbacontinuous-forms

Continuous form only referring to the first record


I have a continuous form - one of the fields on the form is RecordID.

I have a label on that form, that when clicked should produce a message box with the RecordID in it via VBA:

MsgBox Me.RecordID

The label is reproduced on each row of the Continuous Form, but will only reference the first record. Even though I can see the RecordID field is different in each row of the form, I always get the same result, in this case 80029.

What's up with that?


Solution

  • Me.RecordID refers to the RecordID of the current record, as indicated by the black triangle in the record selector:

    ContinuousForm

    A Label control on a form cannot receive the Focus, so when you click on the label in another record the current record does not change and you keep getting the same RecordID. Note that if you put the same code into the Click handler for a textbox (or some other control that can receive the Focus) then the current record will change and you'll get the RecordID of that record.