Data Type Mismatch Error in Criteria Expression
Okay, this one is bothering me:
I have two combo boxes on a form, one with a list value of 1-12, and the other with a list value of 2004, and 2005.
The user uses the combo boxes to select a month and year, then clicks a button to pull up a report with data for that month and year. Here is code THAT WORKS:
'=====Code Starts=====
Dim stDocName As String
Dim stMonth As String
Dim stYear As String
Dim stLinkCriteria As String
stMonth = Me.Combo11
stYear = Me.Combo13
stLinkCriteria = "[Month] = " & "'" & stMonth & "'" & " And " & "[Year] = " & "'" & stYear & "'"
stDocName = "rptqryROUNDEDCPUSpeed2"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
'=====Code Ends=====
I built a second report from the same table only changing the CPU speed to RAM quantity, using the same combo boxes but pulling up a similar report, and this code DOES NOT WORK:
'=====Code Starts=====
Dim stDocName As String
Dim stMonth As String
Dim stYear As String
Dim stLinkCriteria As String
stMonth = Me.Combo11
stYear = Me.Combo13
stLinkCriteria = "[Month] = " & "'" & stMonth & "'" & " And " & "[Year] = " & "'" & stYear & "'"
stDocName = "rptqryRAMSPEED"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
'=====Code Ends=====
So the very same code works for one report, but not the other. With the second report I get the error listed in the subject line.
What am I overlooking?
mmcdonal
__________________
mmcdonal
Look it up at: http://wrox.books24x7.com
|