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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch when try to print report

Status
Not open for further replies.

gc

MIS
Mar 8, 2001
68
US
Hi!
I'm not sure where to post my question, so I select this topic.
I have a Main Menu form to print a lot of reports. I use the combination of several unbound fields to select a report, such as report type and Company,Team,Staff,etc. Then use a Print button to print selected report. The problem is that after print first report, when I try to print second report, I got "Type Mismatch" error message. If I close the Main Menu form and reopen it the problem is still there. Only I close the Main Menu form and open another form then close it and reopen the Main Menu form, then I can print another report, but only one.
Any help will be greatly appreciated!
Goerge
 
The "Type Mismatch" error probably is not directly related to trying to print the second report. Rather, it is most likely due to an error in your coding. My hunch is that you've used Variant or untyped variables (or you haven't Dim'ed them at all), and that in the process of printing the first report you've left some value assigned to one. Then, when you come back through the code for the second report, it has an incompatible value and causes the error. But that's just a hunch; there are other possibilities.

Show us the code--the whole module, if it's not too big, otherwise at least start with the procedure where the error occurs. And please indicate on what line the error occurs. It would also help if you could give us the values of the variables in that line when the error occurs. Rick Sprague
 
Hi! Rick,
Thank you very much for your quick response!
The code is prety long so I just post part of them ( other part is similar). Every time just print one report and after print I clean all the entries (near the end of code). The type of select fields are date, check box, and text combo box. The row source of comboboxs are from table or query. The error messagge displayed after press Print button. This is my code:

Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_click

Dim rptname As String

DoCmd.Hourglass True

'====================================== periodic reprots

If Me!chkPeriod = -1 Then
If IsNull(Me![StartDate_Rpt]) = True Then
MsgBox "Please enter a start date!", vbExclamation + vbOKOnly, "Need a Start Date!"
Me![StartDate_Rpt].SetFocus
Else
If IsNull(Me![EndDate_Rpt]) = True Then
MsgBox "Please enter an end date of the period!", vbExclamation + vbOKOnly, "Need an End Date!"
Me![EndDate_Rpt].SetFocus
Else
If ((Me![EndDate_Rpt]) < (Me![StartDate_Rpt])) Then
MsgBox &quot;End date must be greater than Start date, please enter another date.&quot;, vbExclamation + vbOKOnly, &quot;Wrong End Date!&quot;
Me![EndDate_Rpt] = &quot;&quot;
Me![EndDate_Rpt].SetFocus
Else

If Me!chkTeamSummaryOnly_P = -1 Then rptname = &quot;rptTeamSummaryOnly_P&quot;

'-------------- Missing Notes reports
If Me!chkNoteMissing = -1 Then
Call MissingNotes
If Me!chkCompany = -1 Then rptname = &quot;rptMissingNotes_P&quot;
If Me!chkTeam = -1 Then
If IsNull(Me!Team) = True Then
MsgBox &quot;Please select a team&quot;, vbExclamation + vbOKOnly, &quot;Need a Team!&quot;
Me!Team.SetFocus
Else
rptname = &quot;rptMissingNotes_Team_P&quot;
End If
End If
If Me!chkNurse = -1 Then
If IsNull(Me!Staff) = True Then
MsgBox &quot;Please select a Field Staff&quot;, vbExclamation + vbOKOnly, &quot;Need a Staff Name!&quot;
Me!Staff.SetFocus
Else
rptname = &quot;rptMissingNotes_Staff_P&quot;
End If
End If
If Me!chkPt = -1 Then
If IsNull(Me!Patient) = True Then
MsgBox &quot;Please select a patient&quot;, vbExclamation + vbOKOnly, &quot;Need a Patient Name!&quot;
Me!Patient.SetFocus
Else
rptname = &quot;rptMissingNotes_Patient_P&quot;
End If
End If
End If

'-----------Missing visits reports
If Me!chkVisitMissing_P = -1 Then
If Me!chkCompany = -1 Then rptname = &quot;rptMissingVisits_P&quot;

If Me!chkTeam = -1 Then
If IsNull(Me!Team) = True Then
MsgBox &quot;Please select a team&quot;, vbExclamation + vbOKOnly, &quot;Need a Team!&quot;
Me!Team.SetFocus
Else
rptname = &quot;rptMissingVisits_Team_P&quot;
End If
End If
If Me!chkNurse = -1 Then
If IsNull(Me!Staff) = True Then
MsgBox &quot;Please select a Field Staff&quot;, vbExclamation + vbOKOnly, &quot;Need a Staff Name!&quot;
Me!Staff.SetFocus
Else
rptname = &quot;rptMissingVisits_Staff_P&quot;
End If
End If
If Me!chkPt = -1 Then
If IsNull(Me!Patient) = True Then
MsgBox &quot;Please select a patient&quot;, vbExclamation + vbOKOnly, &quot;Need a Patient Name!&quot;
Me!Patient.SetFocus
Else
rptname = &quot;rptMissingVisits_Patient_P&quot;
End If
End If
End If

'-------------summary reports
If Me!chkSummary = -1 Then

If Me!chkTeamSummaryOnly_P = -1 Then rptname = &quot;rptTeamSummaryOnly_P&quot;

If Me!chkCompany = -1 Then
rptname = &quot;rptCompanySummary_P&quot;
DoCmd.OpenReport rptname, acViewNormal
rptname = &quot;subrptCompanySummary_OtherTeam_P&quot;
End If
If Me!chkTeam = -1 Then
If IsNull(Me!Team) = True Then
MsgBox &quot;Please select a team&quot;, vbExclamation + vbOKOnly, &quot;Need a Team!&quot;
Me!Team.SetFocus
Else
rptname = &quot;rptTeamSummary_P&quot;
End If
End If
If Me!chkNurse = -1 Then
If IsNull(Me!Staff) = True Then
MsgBox &quot;Please select a Field Staff&quot;, vbExclamation + vbOKOnly, &quot;Need a Staff Name!&quot;
Me!Staff.SetFocus
Else
rptname = &quot;rptStaffSummary_P&quot;
End If
End If
If Me!chkPt = -1 Then
If IsNull(Me!Patient) = True Then
MsgBox &quot;Please select a patient&quot;, vbExclamation + vbOKOnly, &quot;Need a Patient Name!&quot;
Me!Patient.SetFocus
Else
rptname = &quot;rptPatientSummary_P&quot;
End If
End If
End If
DoCmd.OpenReport rptname, acViewNormal
DoCmd.Hourglass False
DoCmd.SetWarnings True
Me!chkPeriod = &quot;&quot;
Me!StartDate_Rpt = &quot;&quot;
Me!EndDate_Rpt = &quot;&quot;
Me!chkSummary = &quot;&quot;
Me!chkVisitMissing = &quot;&quot;
Me!chkNoteMissing = &quot;&quot;
Me!chkTeamSummaryOnly_P = &quot;&quot;
Me!chkTeamSummaryOnly_Wk = &quot;&quot;
Me!chkVisitMissing_P = &quot;&quot;
Me!chkVisitMissing_Wk = &quot;&quot;
Me!chkCompany = &quot;&quot;
Me!chkTeam = &quot;&quot;
Me!Team = &quot;&quot;
Me!chkNurse = &quot;&quot;
Me!Staff = &quot;&quot;
Me!chkPt = &quot;&quot;
Me!Patient = &quot;&quot;
Exit Sub
End If
End If
End If
End If

Exit_cmdPrint_click:
DoCmd.Hourglass False
DoCmd.SetWarnings True
Exit Sub

Err_cmdPrint_click:
MsgBox Error$
Resume Exit_cmdPrint_click
End Sub

Thanks again!
George
 
Hi! Rick,
I solved this problem. When Clean up all the entries, I set null. This is wrong for check box, it shouild be 0.
Thank you very much for your idea.
George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top