Hi, sorry to bring this back up but I felt due to the high number of replies the post was getting ignored. Here's my problem. The code below is what I use to filter a form. A quick scan over makes it pretty simple to understand what's going on. When it filters the form it runs the command DoCmd.OpenForm stDocName, , , stLinkCriteria. I only want it to run that command if it finds a records otherwise it displays a msgbox saying "Not Found".
I'd be greatful if anyone could help. Thanks
Private Sub cmdFilter_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim Result As Integer
Rem Declaring the formname
stDocName = "frmHouses"
Rem Filtering Minimum Price
If IsNumeric(txtMinimumPrice) = True Then
stLinkCriteria = "[H_PRICE] >=" & Me![txtMinimumPrice]
Else
Rem Added to avoid a possible error
stLinkCriteria = "[H_PRICE] >= 0"
End If
Rem Filtering Maximum Price
If IsNumeric(txtMaximumPrice) = True Then
stLinkCriteria = stLinkCriteria & "and [H_PRICE] <=" & Me![txtMaximumPrice]
End If
Rem Filtering Region
If IsNull(cboRegion) = False Then
stLinkCriteria = stLinkCriteria & "and [H_REGION] =" & "'" & Me![cboRegion] & "'"
End If
Rem Filtering number of Rooms
If IsNumeric(txtRooms) = True Then
stLinkCriteria = stLinkCriteria & "and [H_BEDS] =" & Me![txtRooms]
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
I'd be greatful if anyone could help. Thanks
Private Sub cmdFilter_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim Result As Integer
Rem Declaring the formname
stDocName = "frmHouses"
Rem Filtering Minimum Price
If IsNumeric(txtMinimumPrice) = True Then
stLinkCriteria = "[H_PRICE] >=" & Me![txtMinimumPrice]
Else
Rem Added to avoid a possible error
stLinkCriteria = "[H_PRICE] >= 0"
End If
Rem Filtering Maximum Price
If IsNumeric(txtMaximumPrice) = True Then
stLinkCriteria = stLinkCriteria & "and [H_PRICE] <=" & Me![txtMaximumPrice]
End If
Rem Filtering Region
If IsNull(cboRegion) = False Then
stLinkCriteria = stLinkCriteria & "and [H_REGION] =" & "'" & Me![cboRegion] & "'"
End If
Rem Filtering number of Rooms
If IsNumeric(txtRooms) = True Then
stLinkCriteria = stLinkCriteria & "and [H_BEDS] =" & Me![txtRooms]
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub