D
Dave
I am trying to use a report dialog form that has three
fields that will be used to filter the SQL in the report.
I've included the print report code that gets called form
the report dialog box below:
PROBLEM:
One is a text field so that the user can enter a wildcard
term. This works fine. I can enter a value and it calls
the report and executes correctly with the filter.
The other two fields are text boxes that the user can
enter dates into and then I add a > then the start date
and/or a < the end date. They can enter one or the other
or both (why I'm not using between). Oh, and I also have a
calendar control that lets them pick the dates from. It
returns the date into the date text boxes.
It works for the two dates fields if I have no format mask
and I do not using the calendar control. In this case I
get the msgbox that prints out the syntax of the
strWhereCategory. Everything works fine, it generates the
report with the filter for the dates.
The problem is when I either a: add a format mask (i.e.
dd/mmm/yyy) to the date text boxes or I use the calendar
control and return the values into the date text boxes.
In both cases, I do not even get the MsgBox debug
message. The report dialog doesn't nothing at this
point. Although it works if I manually enter the date
values with no format mask on the text fields, I really
want to use a format mask and especially the calendar
control to make it easier for the user.
Anyone have any ideas as to why the format mask and the
calendar control affect the field so that it does not work?
PRINT REPORT CODE
=================
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click
Sub procedures.
' Preview or print report selected in the
ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
If (Not IsNull(Forms!sfrmRptDialogTerms1!
txtStartDate)) Then
strWhereCategory = " LOGIN_DATE > #" + Forms!
sfrmRptDialogTerms1!txtStartDate + "#"
End If
MsgBox " sqlwhere clause=" + strWhereCategory
If (Not IsNull(Forms!sfrmRptDialogTerms1!txtEndDate))
Then
If Not IsNull(strWhereCategory) Then
strWhereCategory = strWhereCategory + " AND "
End If
strWhereCategory = strWhereCategory + "LOGIN_DATE <
#" + Forms!sfrmRptDialogTerms1!txtEndDate + "#"
End If
MsgBox " sqlwhere clause=" + strWhereCategory
Select Case Me!ReportToPrint.Value
Case 1
DoCmd.OpenReport "RptDistinctTermsList",
PrintMode, , strWhereCategory
Case 2
If (Not IsNull(Forms!sfrmRptDialogTerms1!
fWildCardCriteria)) Then
If Not IsNull(strWhereCategory) Then
strWhereCategory = strWhereCategory + "
AND "
End If
strWhereCategory = strWhereCategory + "
QUERY_TERMORPHRASE like " + "'*" + Forms!
[sfrmRptDialogTerms1]!fWildCardCriteria + "*'"
' MsgBox "sqlwhere clause=" +
strWhereCategory
End If
DoCmd.OpenReport "RptDistinctTermsList",
PrintMode, , strWhereCategory
End Select
DoCmd.Close acForm, "sfrmRptDialog1"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
fields that will be used to filter the SQL in the report.
I've included the print report code that gets called form
the report dialog box below:
PROBLEM:
One is a text field so that the user can enter a wildcard
term. This works fine. I can enter a value and it calls
the report and executes correctly with the filter.
The other two fields are text boxes that the user can
enter dates into and then I add a > then the start date
and/or a < the end date. They can enter one or the other
or both (why I'm not using between). Oh, and I also have a
calendar control that lets them pick the dates from. It
returns the date into the date text boxes.
It works for the two dates fields if I have no format mask
and I do not using the calendar control. In this case I
get the msgbox that prints out the syntax of the
strWhereCategory. Everything works fine, it generates the
report with the filter for the dates.
The problem is when I either a: add a format mask (i.e.
dd/mmm/yyy) to the date text boxes or I use the calendar
control and return the values into the date text boxes.
In both cases, I do not even get the MsgBox debug
message. The report dialog doesn't nothing at this
point. Although it works if I manually enter the date
values with no format mask on the text fields, I really
want to use a format mask and especially the calendar
control to make it easier for the user.
Anyone have any ideas as to why the format mask and the
calendar control affect the field so that it does not work?
PRINT REPORT CODE
=================
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click
Sub procedures.
' Preview or print report selected in the
ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
If (Not IsNull(Forms!sfrmRptDialogTerms1!
txtStartDate)) Then
strWhereCategory = " LOGIN_DATE > #" + Forms!
sfrmRptDialogTerms1!txtStartDate + "#"
End If
MsgBox " sqlwhere clause=" + strWhereCategory
If (Not IsNull(Forms!sfrmRptDialogTerms1!txtEndDate))
Then
If Not IsNull(strWhereCategory) Then
strWhereCategory = strWhereCategory + " AND "
End If
strWhereCategory = strWhereCategory + "LOGIN_DATE <
#" + Forms!sfrmRptDialogTerms1!txtEndDate + "#"
End If
MsgBox " sqlwhere clause=" + strWhereCategory
Select Case Me!ReportToPrint.Value
Case 1
DoCmd.OpenReport "RptDistinctTermsList",
PrintMode, , strWhereCategory
Case 2
If (Not IsNull(Forms!sfrmRptDialogTerms1!
fWildCardCriteria)) Then
If Not IsNull(strWhereCategory) Then
strWhereCategory = strWhereCategory + "
AND "
End If
strWhereCategory = strWhereCategory + "
QUERY_TERMORPHRASE like " + "'*" + Forms!
[sfrmRptDialogTerms1]!fWildCardCriteria + "*'"
' MsgBox "sqlwhere clause=" +
strWhereCategory
End If
DoCmd.OpenReport "RptDistinctTermsList",
PrintMode, , strWhereCategory
End Select
DoCmd.Close acForm, "sfrmRptDialog1"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub