Help with conditional search

YoungNastyMan

New member
Local time
Today, 16:44
Joined
Jun 27, 2006
Messages
5
Hi I've search the form for this and although I have found answers they are all in Access 2000 or above which I cannot open as I am limited to Access 97. My problem is this I am using a form with three combo boxes (article, line and process) to put data to a query (search) while this works fine if all fields are filled it wont work if any of the fields are left blank. What SQL code would I need to put a condition that if the field is blank it would be left out of the query? I'd really appreciate some help.
Thanks
 
Im assuming you're using a button or something to trigger the search?
In the on click event of the button put an if check... for example

Code:
if isNull(article.Value) And isNull(line.Value) And isNull(process.Value) Then 'If they're all empty then show a message
    MsgBox "Fill in the fields first!"
ElseIf Not isNull(article.Value) And isNull(line.Value) And isNull(process.Value) Then ' If they're all full then do the search
    DoTheSearchFunction
Else 'All other possibilities
    MsgBox "One or more of the fields is empty, please fill them in first!"
EndIf
 
Last edited:
What SQL code would I need to put a condition that if the field is blank it would be left out of the query?

Add a condition on the query field you're comparing against the value of your combo box.
Would be something like

Code:
tablename.columnname = Forms!formname!comboname
OR Forms!formname!comboname Is Null

RV
 

Users who are viewing this thread

Back
Top Bottom