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!

VBA Problems

Status
Not open for further replies.

Peanut2232425

IS-IT--Management
Feb 14, 2001
14
0
0
US
It is telling me that I have a Mismatch Type error. Here is my code. I can't tell anywhere where there is one. Can some one please help!!!


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
 
Not sure it is the entire problem, but you are doing a boolean test of an integer value -- no can do:

'If IWhere Then' is the first thing I would look at.
Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top