help with vba

Toeying

Registered User.
Local time
Today, 22:34
Joined
Jul 30, 2010
Messages
79
Hello all,
I have the following code running and keep getting the above error. all looks fine to me . can somebody please help?

Private Sub cmdShowRecord_Click()
Dim rs As DAO.Recordset
Set rs = Forms!frmSAHCarerdetails.RecordsetClone

Call rs.FindFirst("SAHCarerReferenceNumber=" & Me.lstSelectRecord.Value)
Forms!frmSAHCarerdetails.Recordset.Bookmark = rs.Bookmark
Call DoCmd.Close(acForm, "frmSelectRecord")

End Sub

frmSAHCarerdetails is the form I want to go to when a record from lstSelectRecord is selected.

many thanks
 
You do not need the Call command syntax
 
hmm ok, but the program does not even run to that point. it stalls at the set rs= Forms!.... line.
 
Is the form frmSAHCarerdetails open at the point for running the code? If so what error is being thown?
 
thanks. it wasnt open at first but now i ran it now with the form being open. but the error has now changed to microsoft jet engine does not recognise 'SAH1' as a valid filename or expression. SAH1 is the ID I am passing from the lstSelectRecord in line 4 of the above code (i.e call...)
Thanks
 
thanks. it wasnt open at first but now i ran it now with the form being open. but the error has now changed to microsoft jet engine does not recognise 'SAH1' as a valid filename or expression. SAH1 is the ID I am passing from the lstSelectRecord in line 4 of the above code (i.e call...)
Thanks
SAH1 is not listed in your code
 
yes. SAH1 is the ID for one of the records in my database. There will be SAH1,SAH2, SAH3 and so on. When a record is click from the list box lstSelectRecord, this is ID is passed to identify which record has been selected to be opened...I hope that makes sense.
Thanks
 
Because you have not parsed the cod correctly Access thinks this is a field name. Change it to

Code:
rs.FindFirst("SAHCarerReferenceNumber='" & Me.lstSelectRecord & "'")
 
Is the form frmSAHCarerdetails open at the point for running the code? If so what error is being thown?

just one more question. I would prefer not need to have the form open to run this functionality. I want the use r to be able to open the frm with the list box first. and then on clicking open selected, this othe form i.e frmSAHCarerdetails should come up.. thanks
 
Then you need to apply On Open Arguments to apply a filter to the form being opened
 
hmm that sounds quite complex for me (newbie). what I have done is added a command button and used the wizard to link it up with the form and record to be opened using the ID passed from the record selected in the list box. that works fine for now.thanks for all your help. see u around...I still have loads of questions..:)
 
Then you need to apply On Open Arguments to apply a filter to the form being opened

hello DCrake, can you please tell me where I will put the On Open arguments? thanks.
 

Users who are viewing this thread

Back
Top Bottom