List box on pop up form

MooTube

Registered User.
Local time
Today, 14:19
Joined
Jul 2, 2015
Messages
31
Hello,

I currently have a list box that filters though a list of records on the main form using a text box.

I have got the search function working, and the list box filters correctly, the problem I am having is that I need to be able to double click the record and have that record show on the main form.

The code I have so far is...

Code:
Private Sub SearchResults_DblClick(Cancel As Integer)

    DoCmd.OpenForm "PersonDetailsForm", , , "[PersonID] = '" & Me.[SearchResults].Column(0).Value & "'"

End Sub

With the name of my form being PersonDetailsForm, the name of the field I am trying to get to being PersonID and the name of the listbox being SearchResults, with the searched PersonID living in the first column (column0) of this list box.

When I run this code and double click on a specified record, I recieve the error "Run-time error '424': Object Required

I don't understand why this happens? Is it because the value is numerical? Any help would be greatly appreciated!
 
it IS numerical. you dont need to call column 0, its default.

DoCmd.OpenForm "PersonDetailsForm", , , "[PersonID] = " & Me.[SearchResults]
 
looks like you're putting single quotes around the number making it a string value instead of a number. Try like Ranman's statement or get rid to the single quotes around the number
 
Perfect thank you, I didn't realise that a list box would contain column 0 as default or that I was setting it to a string value! Thanks for the help guys I learnt more than I thought I would!!!
 

Users who are viewing this thread

Back
Top Bottom