Renier Duvenhage
Renier Duvenhage

Reputation: 21

Open Form to specific record

I'm struggling with a code I found on Stackoverflow. It keeps on telling me:

run-time error "424: object required".

I want to double-click on a record within a list box to open a form to the specific record clicked. The value from the record that I need the form to navigate to is found in Column 1 of the list box.

List Box Name: frmDashboardJBCreate
Field name in the table: JobcardNumber (numeric field)
Form Name: frmJobcardCreate
Table Name: tabJobcard_Issue

The code I tried is the following; but it keeps on giving me the error mentioned above:

DoCmd.OpenForm "frmJobcardIssue", , , _
    "[JobcardNumber] = '" & Me.frmDashboardJBCreate.Column(1).Value & "'"

Could you please assist me?

Upvotes: 1

Views: 1266

Answers (1)

Andre
Andre

Reputation: 27634

If JobcardNumber is numeric, don't use single quotes around the parameter.

ListBox.Column() is zero-based, so if you want the first column, it's

DoCmd.OpenForm "frmJobcardIssue", , , _
    "[JobcardNumber] = " & Me.frmDashboardJBCreate.Column(0).Value

Note: frm usually stands for "Form", so it is rather confusing if you name a listbox frmDashboardJBCreate. Are you sure you have that name right?

Upvotes: 0

Related Questions