ApplyFilter Not Working

  • Thread starter Thread starter bw
  • Start date Start date
B

bw

All of a sudden, the following procedure doesn't work anymore, and I can't
figure out why.
The Filter is NOT applied, and the MsgBox displays the wrong Hotel.

Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "HotelID = 30"
MsgBox Hotel
End Sub

Can anyone give me some hints as to what may be the problem?

Thanks,
Bernie
 
I should have pointed out that MsgBox HotelID = 36, and is the first record
in the file.
Hope this helps someone to help me.
Bernie

Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "HotelID = 30"
MsgBox HotelID
MsgBox Hotel
End Sub
 
bw said:
I should have pointed out that MsgBox HotelID = 36, and is the first record
in the file.
Hope this helps someone to help me.
Bernie

Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "HotelID = 30"
MsgBox HotelID
MsgBox Hotel
End Sub

Try
*************************
Me.Filter = "[HotelID] = 30"
Me.FilterOn = True
******************************

Make sure that your form is set to allow filters.

Although you are better off opening the form with a filter such as:

*******************
DoCmd.OpenForm FormName, acNormal, , "[HotelID] = 30"
*************************
 
Back
Top