Using an Integer from a subform to filter a report.

workingpoor

Registered User.
Local time
Yesterday, 19:33
Joined
Jul 19, 2006
Messages
21
THis has to be an easy issue.

I have a subform that in the on curren event i passes the ClassId out to my main for in an unbound text box

Forms![Student]![ClassID] = Me![ClassID]

I know this part works

I then have a command button that should pass ClassID to a report so that it can be filtered. Here is the on_click code

Private Sub cmdReprintAccom_Click()
On Error GoTo Err_cmdReprintAccom_Click

Dim stDocName As String
Dim strReptCriteria As String

strReptCriteria = ClassID
stDocName = "Forms - Accomodations"
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ClassID] = '" & strReptCriteria & "'"

My problem is that I keep getting a type mismatch error. I know that it is because CLassID is a number and it is getting passed as a string i just can't figure out the syntax to the highlighted code.
 
Don't use quotes!

strReptCriteria = "[ClassID] = " & Me.ClassID
stDocName = "Forms - Accomodations"
DoCmd.OpenReport stDocName, acViewPreview, , strReptCriteria
 
I did a little changing

I did a little more work and i have gotten rid of the type mismatch error. Now i am gettting a dialog box asking for a parameter value. Something has to be wrong with the last line of code where i set the parameter value to equal the variable reptcriteria. Am I having a problem because ClassID is an integer?

Dim stDocName As String
Dim ReptCriteria As Integer
ReptCriteria = Me![LinkClassID]
stDocName = "Forms - Accomodations"
DoCmd.OpenReport stDocName, acViewPreview, , _
"[ClassID] = [ReptCriteria] "
 
Oopss

Your suggestion totally worked rural guy..

Sorry... When I refreshed my browser it didn't show your post...

Thanks again
 

Users who are viewing this thread

Back
Top Bottom