IF statement in SELECT query? (1 Viewer)

Henley12

Troy University Fan
Local time
Today, 07:30
Joined
Oct 10, 2007
Messages
222
I have an odd situation. I am trying to program a combo box to select two different sets of criteria depending on the value in a text box on the form. For example, when I open up the form, it is pulling in a Manufacturer name from another form based on the Equipment ID. But if the equipment id is 'miscellaneous', the newly opened form field will have 'misc' in the text box. If the text box has 'misc', I want the combo box to display all choices from the underlying query. If the text box has the name of a manufacturer, I want it to only display those records in the combo box. I hope this makes sense.
 

JPearson

Registered User.
Local time
Today, 08:30
Joined
Dec 23, 2009
Messages
54
Sounds more like you should use VBA to change and refresh the query of that cbo box.
 

CraigDolphin

GrumpyOldMan in Training
Local time
Today, 05:30
Joined
Dec 21, 2005
Messages
1,582
or use a criteria expression along the lines of:
Code:
Like IIF(Forms!Formname!textboxname = 'misc','*',Forms!Formname!textboxname)

You should also trap for nulls in case the value in the textbox is empty
 

Henley12

Troy University Fan
Local time
Today, 07:30
Joined
Oct 10, 2007
Messages
222
or use a criteria expression along the lines of:
Code:
Like IIF(Forms!Formname!textboxname = 'misc','*',Forms!Formname!textboxname)
You should also trap for nulls in case the value in the textbox is empty


That worked like a charm. Anyone else have those days when you just feel like an idiot? Thanks for the help.
 

CraigDolphin

GrumpyOldMan in Training
Local time
Today, 05:30
Joined
Dec 21, 2005
Messages
1,582
I'm married. There is no respite from ego deflation even on weekends ;)
 

vbaInet

AWF VIP
Local time
Today, 13:30
Joined
Jan 22, 2010
Messages
26,374
Short breaks away (once in a while) would help. Then again, if the wife approves :)
 

Users who are viewing this thread

Top Bottom