Hi,
I have a small database which connects projects, organizations and contact persons for organizations.
My search for projects is based on many criterias. For example I need a project with scope 1, priority status 2 and it is approved, or funding year is 2002-2003 , scope is 3 and priority status is 2.......
For all these options I have couple of combo boxes on my search form and one button which I press and get another form which desplays data according to criteria.
Everything works fine, but when there is no data which satisfy criteria, after I presss the button my result list is empty (not without data but without any control on it, just empty screen).
That's why I tried to put message box to show up if my filter string is empty but the message box is ignored. I'm still pretty new in VBA ..........
The code for the button's event onclick is next
Private Sub cmdFindRecords_Click()
Dim strFilter As String
strFilter = ""
If Not IsNull(Me!cboScope) Then strFilter = strFilter & "[Scope]=" & Chr(34) & Me!cboScope & Chr(34) & "AND"
If Not IsNull(Me!cboPriorityStatus) Then strFilter = strFilter & "[PriorityStatus]=" & Me!cboPriorityStatus & "AND"
If Not IsNull(Me!cboApprovalStatus) Then strFilter = strFilter & "[ApprovalStatus]=" & Chr(34) & Me!cboApprovalStatus & Chr(34) & "AND"
If strFilter <> "" Then
strFilter = Left$(strFilter, Len(strFilter) - 3)
DoCmd.OpenForm "ResultForm", , , strFilter, acFormReadOnly
Else
MsgBox "There is no matching data"
End If
End Sub
I work in Access 2000
Any suggestions?
I have a small database which connects projects, organizations and contact persons for organizations.
My search for projects is based on many criterias. For example I need a project with scope 1, priority status 2 and it is approved, or funding year is 2002-2003 , scope is 3 and priority status is 2.......
For all these options I have couple of combo boxes on my search form and one button which I press and get another form which desplays data according to criteria.
Everything works fine, but when there is no data which satisfy criteria, after I presss the button my result list is empty (not without data but without any control on it, just empty screen).
That's why I tried to put message box to show up if my filter string is empty but the message box is ignored. I'm still pretty new in VBA ..........
The code for the button's event onclick is next
Private Sub cmdFindRecords_Click()
Dim strFilter As String
strFilter = ""
If Not IsNull(Me!cboScope) Then strFilter = strFilter & "[Scope]=" & Chr(34) & Me!cboScope & Chr(34) & "AND"
If Not IsNull(Me!cboPriorityStatus) Then strFilter = strFilter & "[PriorityStatus]=" & Me!cboPriorityStatus & "AND"
If Not IsNull(Me!cboApprovalStatus) Then strFilter = strFilter & "[ApprovalStatus]=" & Chr(34) & Me!cboApprovalStatus & Chr(34) & "AND"
If strFilter <> "" Then
strFilter = Left$(strFilter, Len(strFilter) - 3)
DoCmd.OpenForm "ResultForm", , , strFilter, acFormReadOnly
Else
MsgBox "There is no matching data"
End If
End Sub
I work in Access 2000
Any suggestions?