How to Tweak Criteria Line in query

  • Thread starter Thread starter doyle60
  • Start date Start date
D

doyle60

I have a check box called "Plnt9999" on a form called
DOSDialogPrintfrm. When it is checked, I want a query to include all
records. When it is not checked, I want the query to exclude only the
values "9999" (which are text data) but include all others.

The below formula does not work. How do I get it to work?

Like (IIf([Forms]![DOSDialogPrintfrm]![Plnt9999]=0,"*",<>"9999"))

The "*" bit is working but the <>"9999" is not. Thanks,

Matt
 
You can't change the structure of a query with a parameter. You are trying
to have your query say "Where somefield Like *" in one case and "Where
somefield <> '9999'" in the other. The only way to do this is to create the
SQL string in VBA. Querydefs only support static SQL with or without
paramters. Dynamic SQL must be created with code. An alternative is to use
two querydefs and have your code run one or the other depending on a form
field value.
 
Thanks Duane. Your suggestion worked once I changed the "0" to "-1".
But can you tell me about those "~~~~~" tildes? I cannot find any
guide about them. Why five? Etc. Thanks,

Matt
 
The multiple tildes are just a string value that I really doubt is stored in
your table. It could have been "ZZZZZ" or "XXXX" or almost any other obscure
value.
 
Back
Top