Jay
Jay

Reputation: 1216

How to get record number in a continuous form?

I am creating a form in MS Access. Its "detail" section is set to "continuous form". I am filtering the result based on some criteria, so that when the form runs, it shows only filtered results.

I have also included a command button in the details section of the same form.

When I click that command button, which appears in front of every record in the filtered results in the form, I want to display a message box. The message box shall display the ID (which is autonumbered) for that particular record.

I am trying something like this:

Private Sub cmdSelect_Click()

    Dim MyDB As DAO.Database
    Dim MyRec As DAO.Recordset

    Set MyDB = CurrentDb
    Set MyRec = MyDB.Recordsets

    MsgBox MyRec![Artifact ID]

    'MsgBox CurrentRecord![Artifact ID]

    Set MyDB = Nothing
    Set MyRec = Nothing

End Sub

However, it gives an error.

Please help me.

Thank you.

Upvotes: 0

Views: 4827

Answers (1)

Matt Donnan
Matt Donnan

Reputation: 4993

Continuous forms are Bound so there is no need to refer to any additional recordsets as it's already there, instead and as long as Artifact ID is part of the form's recordsource you should be able to use this for the on click event:

MsgBox [Artifact ID]

Or if necessary:

Msgbox Me.[Artifact ID]

Upvotes: 1

Related Questions