R
rstiles
Good morning everyone,
First off I need to thank Marsh for giving me the outline for the
following code, I would not have been able to continue with this
application without it.
I have entered this code under my search command button and after
writing it all I am getting "Compile error: Block If without If" when I
try to debug the code (see below). I have heard that Access 2003 has
done this in past when there is not a problem with the code. Would you
guys be willing to take a look...
Private Sub cmdSearch_Click()
Dim strWhere As String
Dim strSQL As String
Dim strSort As String
strSQL = "SELECT
Date,CaseNumber,Officer,OfficerNumber,Incident,Description FROM
tblCaseNumber "
strSort = " ORDER BY CaseNumber, DESC"
If Not IsNull(tbxDate) Then
strWhere = strWhere & " AND Date=" _
& Format(tbxDate, "\#m\/d\/yyyy\#")
'date field
If Not IsNull(tbxCaseNumber) Then
strWhere = strWhere & " AND CaseNumber=""" & tbxCaseNumber &
"""" 'text
If Not IsNull(tbxOfficer) Then
strWhere = strWhere & " AND Officer=""" & tbxOfficer & """"
'text
If Not IsNull(tbxOfficerNumber) Then
strWhere = strWhere & " AND OfficerNumber=""" &
tbxOfficerNumber & """" 'text
If Not IsNull(tbxIncident) Then
strWhere = strWhere & " AND Incident=""" & tbxIncident & """"
'text
If Not IsNull(tbxDescription) Then
strWhere = strWhere & " AND Description=""" & tbxDescription &
"""" 'text
End If
Me.lstCNSearch.RowSource = strSQL & Mid(strWhere, 6) & strSort
End Sub
Thankyou,
Ron
First off I need to thank Marsh for giving me the outline for the
following code, I would not have been able to continue with this
application without it.
I have entered this code under my search command button and after
writing it all I am getting "Compile error: Block If without If" when I
try to debug the code (see below). I have heard that Access 2003 has
done this in past when there is not a problem with the code. Would you
guys be willing to take a look...
Private Sub cmdSearch_Click()
Dim strWhere As String
Dim strSQL As String
Dim strSort As String
strSQL = "SELECT
Date,CaseNumber,Officer,OfficerNumber,Incident,Description FROM
tblCaseNumber "
strSort = " ORDER BY CaseNumber, DESC"
If Not IsNull(tbxDate) Then
strWhere = strWhere & " AND Date=" _
& Format(tbxDate, "\#m\/d\/yyyy\#")
'date field
If Not IsNull(tbxCaseNumber) Then
strWhere = strWhere & " AND CaseNumber=""" & tbxCaseNumber &
"""" 'text
If Not IsNull(tbxOfficer) Then
strWhere = strWhere & " AND Officer=""" & tbxOfficer & """"
'text
If Not IsNull(tbxOfficerNumber) Then
strWhere = strWhere & " AND OfficerNumber=""" &
tbxOfficerNumber & """" 'text
If Not IsNull(tbxIncident) Then
strWhere = strWhere & " AND Incident=""" & tbxIncident & """"
'text
If Not IsNull(tbxDescription) Then
strWhere = strWhere & " AND Description=""" & tbxDescription &
"""" 'text
End If
Me.lstCNSearch.RowSource = strSQL & Mid(strWhere, 6) & strSort
End Sub
Thankyou,
Ron