I have a form which allows user to select and report and filter options to create reports on the fly. All works fine as long as the filter is on a text field. If it is on a yes/no field or a date field, I get a data conflict message. I understand that any number value in quotes "" is interpreted as text in vba and I suspect that that is the problem. How can I get around this. below is the code: Thanks much
Private Sub cmdPrint_Click()
'On Error GoTo cmdPrint_ClickError
Dim strFilter As String
Dim rpt As Report
Dim strInfo As String
strReportName = Me![cboSelectReport]
strFieldName = Me![cboSelectField]
strFilter = "[" & strFieldName & "] " & strValueList
strInfo = "Filtered by " & strFilter
Debug.Print "Filter: " & strFilter
DoCmd.OpenReport strReportName, acViewPreview
Set rpt = Reports(strReportName)
rpt.OrderByOn = True
rpt.OrderBy = strFieldName
rpt.FilterOn = True
rpt.Filter = strFilter
'DoCmd.OpenReport strReportName, acViewPreview
rpt![txtSort] = strInfo
cmdPrint_ClickExit:
Exit Sub
cmdPrint_ClickError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume cmdPrint_ClickExit
End Sub
Private Sub cmdPrint_Click()
'On Error GoTo cmdPrint_ClickError
Dim strFilter As String
Dim rpt As Report
Dim strInfo As String
strReportName = Me![cboSelectReport]
strFieldName = Me![cboSelectField]
strFilter = "[" & strFieldName & "] " & strValueList
strInfo = "Filtered by " & strFilter
Debug.Print "Filter: " & strFilter
DoCmd.OpenReport strReportName, acViewPreview
Set rpt = Reports(strReportName)
rpt.OrderByOn = True
rpt.OrderBy = strFieldName
rpt.FilterOn = True
rpt.Filter = strFilter
'DoCmd.OpenReport strReportName, acViewPreview
rpt![txtSort] = strInfo
cmdPrint_ClickExit:
Exit Sub
cmdPrint_ClickError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume cmdPrint_ClickExit
End Sub