how to send a value from a form to a reprt in access 2013


i have a veriable in a form that contain some sql string and i want to send this value to a report recordsorce and then open this report based on this sql source

i wrote this code in the report

Public Sub ControlReport(a As String)
If Not IsNull(a) And Not a <> "" Then
    Me.RecordSource = a
End If
End Sub

Open in new window

and in the form i have this code
DoCmd.OpenReport "ListProductrsReport", acViewPreview
reports!ListProductrsReport!ontrolReport (sqlString)

Open in new window

but i don't can to compile the code on the form, what is the problem with my code?

thanks a lot
Who is Participating?
QPRConnect With a Mentor Commented:
Is there a 'c' in ControlReport missing from this line?

reports!ListProductrsReport!ontrolReport (sqlString)

bill201Author Commented:
Yes you are right! Embarrassing :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.