G
Guest
Hi,
I'm trying to create a report whereby the user can pick various criteria to
base a report on and then hit the preview button to view the report.
However, I'm getting a 'Type Mismatch' error.
Each criteria is in its own unbound textbox ;
TEXTBOX NAME TABLENAME FIELDNAME
AgentNameSelect AgentDetails NameAgent
CoachSelect AgentDetails Coach
CentreSelectLabel AgentDetails Centre
Text176 DateWeekPeriod Period/Week
The Preview button is found on the Startup Form within the file called 2nd
Level Support Table.
Below is the coding currently being used... What am I doing wrong?
regards,
Private Sub PreviewReport_Click()
On Error GoTo Err_PreviewReport_Click:
Dim pstrCriteria As String
If Not IsNull(Me.AgentNameSelect) Then
pstrCriteria = "[AgentDetails].[NameAgent]='" & Me!AgentNameSelect &
"'And"
End If
If Not IsNull(Me.CoachSelect) Then
pstrCriteria = "[AgentDetails].[Coach]='" & Me!CoachSelect & "'AND "
End If
If Not IsNull(Me.CentreSelectLabel) Then
pstrCriteria = "[AgentDetails].[Centre]='" & Me!CentreSelectLabel &
"'AND "
End If
If Not IsNull(Me.ProductSelect) Then
pstrCriteria = "[Product / Service].[Product / Service]='" &
Me!ProductSelect & "'AND "
End If
If Not IsNull(Me.Combo221) Then
pstrCriteria = "[Reason].[Reason]='" & Me!Combo221 & "'AND "
End If
If Not IsNull(Me.Text176) Then
pstrCriteria = "[DateWeekPeriod].[Period/Week]='" & Me!DateWeekPeriod &
"'"
End If
If Right$(pstrCriteria, 4) + "AND" Then
pstrCriteria = Left$(pstrCriteria, Len(pstrCriteria) - 4)
End If
Select Case SelectReport
Case 1
DoCmd.OpenReport "Employee Case Creation Details", acViewPreview,
pstrCriteria
Case 2
DoCmd.OpenReport "Pending Cases Report", acViewPreview, pstrCriteria
Case 3
DoCmd.OpenReport "Employee Coaching Received", acViewPreview,
pstrCriteria
End Select
Exit_PreviewReport_Click:
Exit Sub
Err_PreviewReport_Click:
MsgBox Error$
Resume Exit_PreviewReport_Click
End Sub
I'm trying to create a report whereby the user can pick various criteria to
base a report on and then hit the preview button to view the report.
However, I'm getting a 'Type Mismatch' error.
Each criteria is in its own unbound textbox ;
TEXTBOX NAME TABLENAME FIELDNAME
AgentNameSelect AgentDetails NameAgent
CoachSelect AgentDetails Coach
CentreSelectLabel AgentDetails Centre
Text176 DateWeekPeriod Period/Week
The Preview button is found on the Startup Form within the file called 2nd
Level Support Table.
Below is the coding currently being used... What am I doing wrong?
regards,
Private Sub PreviewReport_Click()
On Error GoTo Err_PreviewReport_Click:
Dim pstrCriteria As String
If Not IsNull(Me.AgentNameSelect) Then
pstrCriteria = "[AgentDetails].[NameAgent]='" & Me!AgentNameSelect &
"'And"
End If
If Not IsNull(Me.CoachSelect) Then
pstrCriteria = "[AgentDetails].[Coach]='" & Me!CoachSelect & "'AND "
End If
If Not IsNull(Me.CentreSelectLabel) Then
pstrCriteria = "[AgentDetails].[Centre]='" & Me!CentreSelectLabel &
"'AND "
End If
If Not IsNull(Me.ProductSelect) Then
pstrCriteria = "[Product / Service].[Product / Service]='" &
Me!ProductSelect & "'AND "
End If
If Not IsNull(Me.Combo221) Then
pstrCriteria = "[Reason].[Reason]='" & Me!Combo221 & "'AND "
End If
If Not IsNull(Me.Text176) Then
pstrCriteria = "[DateWeekPeriod].[Period/Week]='" & Me!DateWeekPeriod &
"'"
End If
If Right$(pstrCriteria, 4) + "AND" Then
pstrCriteria = Left$(pstrCriteria, Len(pstrCriteria) - 4)
End If
Select Case SelectReport
Case 1
DoCmd.OpenReport "Employee Case Creation Details", acViewPreview,
pstrCriteria
Case 2
DoCmd.OpenReport "Pending Cases Report", acViewPreview, pstrCriteria
Case 3
DoCmd.OpenReport "Employee Coaching Received", acViewPreview,
pstrCriteria
End Select
Exit_PreviewReport_Click:
Exit Sub
Err_PreviewReport_Click:
MsgBox Error$
Resume Exit_PreviewReport_Click
End Sub