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

Getting a "Type Mismatch" Error

Status
Not open for further replies.

Peanut2232425

IS-IT--Management
Feb 14, 2001
14
0
0
US
I need help. If possible could you look at the code below. I keep getting a type mismatch error. I know I am using Boolean b/c of IWhere. The field it is talking about is a text field.

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Report_Open_Err
Dim myDB As Database
Dim repRS As Recordset

Dim SqlCPC As String
Dim IWhere As Integer
Dim DetailTitle As String

SqlCPC = "Select * from CPC "
If Not IsNull(Forms!frmCPCReport.SettlementOfficer) Then
If IWhere Then
DetailTitle = DetailTitle & ", " & Forms!frmCPCReport.SettlementOfficer
SqlCPC = SqlCPC & " and SettlementOfficer like "" & Forms!frmCPCReport.SettlementOfficer & " * """"
Else
DetailTitle = DetailTitle & " For " & Forms!frmCPCReport.SettlementOfficer
SqlCPC = SqlCPC & " where SettlementOfficer like """ & Forms!frmCPCReport.SettlementOfficer & "*"""
IWhere = True
End If
End If

SqlCPC = SqlCPC & ";"

Set myDB = CurrentDb
Set repRS = myDB.OpenRecordset(SqlCPC)
If Not repRS.EOF And Not repRS.BOF Then
Me.RecordSource = SqlCPC
Else
MsgBox "No records to print"
Cancel = True
End If
'If Not Cancel Then DoCmd.Close acForm, "frmCPCReport"
Me!DetailHeader.Caption = Me!DetailHeader.Caption & DetailTitle

Report_Open_Exit:
Exit Sub

Report_Open_Err:
MsgBox Err.Description
Resume Report_Open_Exit

End Sub




 
The sixth line of your module declares IWhere As Integer, not Boolean.

I'm missing something here because even if you declare IWhere as Boolean, I don't see any arguments that would set it to true or false before you check its value with the If statement in line 10.

John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top