Search code examples
ms-access

Access edit record button on continuous subform


I have a form in Access and there is a subform in it as in the screenshot (light purple is main form, dark blue is subform header).

Subform is a continuous form. I have added 2 images to the subform and want to edit a record based on the row ID.

Form with subform

OnClick event of the image, I tried to add a message box to show the values of

Me.ID

or

Me.CurrentRecord

but they both always show the same value for all the rows.

The edit image click will open an Unbound form so in the OpenArgs of the Form I need the Id that is selected and will populate the Unbound Edit form based on the selected ID.

How can I get the pressed image Id of the record in the Contious subform ?


Solution

  • While clicking on the detail section background does select the record where you clicked, clicking on an image doesn't.
    So just clicking on the image won't change the record selection, and you always see the data of the previously selected record.

    While developing / debugging, you should turn on RecordSelectors in the subform, to see what is going on.

    You need an actual button to achieve both in one click: select record + do action.

    Solution 1: use a normal button with your image as button image.

    Solution 2: put a transparent button in front of the image.

    In both cases, move your code to the button click event.