I need help to write the code to filter a Recordset called Data1 and a Field called AWEIGHT, when loading a form. I tried the following and it does not work. After the form is opened I only want to be able to search the filtered records. An example would be nice.

Private Sub Form_Load()
Data1.Recordset.Filter = "AWEIGHT > 0"

End Sub

Well reading the help file on this it says that for better performance that you should use a query with a where clause...


strSQL = "SELECT * FROM SomeTable WHERE SomeField = somevalue
Set Rs = Db.OpenRecordset(strSQL,...

Good Luck

I solved my problem by doing the following instead of using a filter.

Private Sub Form_Activate()

If txtWeight > 0 Then
GoTo 2
End If
If txtWeight = 0 Then
GoTo 1
End If
Call Show
End Sub