Filter records on opening a form. (1 Viewer)

pelicanbuyer

Registered User.
Local time
Today, 12:30
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?
 

mahenkj2

Registered User.
Local time
Tomorrow, 01:00
Joined
Apr 20, 2012
Messages
459
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
 

pelicanbuyer

Registered User.
Local time
Today, 12:30
Joined
Dec 11, 2012
Messages
12
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.
 

pelicanbuyer

Registered User.
Local time
Today, 12:30
Joined
Dec 11, 2012
Messages
12
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?
 

mahenkj2

Registered User.
Local time
Tomorrow, 01:00
Joined
Apr 20, 2012
Messages
459
-1 and 0 are two status of a check box.

with regards.
 

Users who are viewing this thread

Top Bottom