Re: Showing certain record only

FrunkaBlunka wrote:
Hi everybody,

I have been trying to work out the easiest way to display certain
records only. In my database I have a toggle button that once pressed
indicates the record/project has being invoiced. Once a project has
being invoiced I would like it to hide itself from selection when
navigating through the database.
Easy enough! I made a query and it works fine but what if I wanted a
toggle button for the whole database so that when its in its down state
it displays all records including the invoiced ones and when in its
upstate shows uninvoiced projects only?

I want to do this with affecting the input for the invoiced button
cause it is important to the overall structure.

My Main form is called frmProject which gets it data from a query
called qryProject.

One way to do it.

I add a frame to a form (framZeros) with 2 option buttons
The option buttons, when selected...
1) assign a value of 1 or 2 to framZeros
2) assigns a value of 1 or null to an unbound textbox (txtZeros)
3) populates a label caption with "Show Zeros" or "Don't Show Zeros"

I have a query that filters a table as the recordsource for a listbox.
I add a field named "Sort" to the table and populate with 1s or 0s,
depending on criteria.

The AfterUpdate procedure, below, assigns a value of 1 or null to the
unbound textbox, txtZeros.

Private Sub framZeros_AfterUpdate()
On Error GoTo framZeros_AfterUpdate

If Me.framZeros.Value = 1 Then
Me.txtZeros = Null
Me.lblZeros.Caption = "Show Zeros"
Me.txtZeros = 1
Me.lblZeros.Caption = "Don't Show Zeros"
End If

Exit Sub

MsgBox Err.Description
Resume Exit_framZeros_AfterUpdate
End Sub

I add the following criteria to the filtering query for the listbox,
referencing the unbound txtZeros textbox on the form

Like "*" & [forms]![frm2007Budget]![txtZeros] & "*"

This criteria will display ALL records if the txtZeros textbox has a
null value and only those records with a 1 assigned in the Sort field
if framZeros assigns a value of 1 to the textbox.

Once the query has been changed with the new criteria, the the list box
must be requeried to show the new filter criteria.