Filter records on opening a form.

pelicanbuyer

Registered User.
Local time
Yesterday, 21:00
Joined
Dec 11, 2012
Messages
12
I have a tick box on the form that says completed. On opening the form with the button from a main menu if the box is ticked to say the record has been completed then it does not show those records, hence i am only working with incomplete data.

I have created all of the above but am unsure how to filter the records on opening the form.

Can anyone help please?
 
Please try something like this in the Load event of form:

Private Sub Form_Load()

Dim strWhere As String
Me.NameofTickbox = -1

If Me.NameofTickbox = -1 Then
strWhere = "[NameofStatusField]=" & "No"

Me.Filter = strWhere

Me.FilterOn = True

End If


End Sub
 
I will try this thank you.

Being a novice I am not entirely sure what should go in [NameOfStatusField] is this the name of the field the data is held in the table? The tick box uses this as the control source.
 
That works great, thank you.

Just finally, what would the code be for it to work the opposite way around so that I could create a button to see completed tasks?

Would I use 1 instead of -1?
 
-1 and 0 are two status of a check box.

with regards.
 

Users who are viewing this thread

Back
Top Bottom