Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ad Hoc report filter

Status
Not open for further replies.

bdm1

Programmer
Feb 4, 2002
75
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top