Set Query Criteria when opening a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a form based on a query which has one field criteria "sold" set as
"yes"

The form has a combo box for the sold field with Yes, No options

At the moment, the form only shows all records where sold = Yes as expected
and wanted.

Is there a way that I can specify the sold field criteria in the RECORD
SOURCE of the form so that I can later change it with the combo box to show
the sold = No records?

--
Cheers
Chas

***************
* Spectrum is Green *
***************
 
Sure. Put a button in the form header or footer. On the On Click event of the
button put some code like so:

Me.RecordSource = "SELECT TableName.* FROM TableName WHERE sold = 0 ORDER
BY TableName.SomeField;"

I'm assuming that the "sold" field is a Yes/No field. If it's text change
the 0 above to "No".

You probably should go crazy and put buttons for Yes and All also on the
form. For Yes put in -1 or "Yes". For All remove the WHERE clause.
 
Dear Jerry,
Thanks for the reply, it gives me another option but since posting the
question I have just fixed it. The Sold Field is a text field with three
options; Sold;Lost;Current

As the form is opened from a "Main" form I put a combo box on there with the
default "Current" in it so users normally see current sales in progress. Once
SOLD or LOST they change thie sold field in the form and the record
disappears. If the want to see SOLD or LOST records they close the form and
repoen it with one of the other selections.

Thanks once again for your advice.
--
Cheers
Chas

***************
* Spectrum is Green *
***************
 
Back
Top