C
Cire via AccessMonster.com
ok in a nutshell, i've got several combo boxes and textboxes in a form that
acts as a seach filter for a set of data. All criteria are optional so the
user can select any criteria he wants. The problem is i'm not capturing the
user input correctly...this is what i use:
'if combo box priority is not empty, capture user input
If Not IsNull(Me.cbx_priority.Value) Then
sqlmainstring = sqlmainstring & " AND request.chg.priority = " & quot
& Me.cbx_priority.Value & quot
End If
'if combo box prod category is not empty, capture user input
If Not IsNull(Me.cbx_prod_cat.Value) Then
sqlmainstring = sqlmainstring & " AND request.chgcat.sym = " & quot &
Me.cbx_prod_cat.Value & quot
End If
If IsNull(Me.cbx_priority.Value) And IsNull(Me.cbx_prod_cat.Value) Then
MsgBox ("You have not entered any criteria, please do so before
searching")
End If
sqlmainstring = sqlmainstring & " ORDER BY request.chg.id DESC "
mainqdf.Sql = sqlmainstring
set mainqdf = nothing
of course before all these is the main sql statemetn with the SELECT, FROM
and WHERE statements.
all these are under the on_click portion of a command button. Right now if i
leave the whole form blank, the msgbox doesnt appear!! instead the
sqlstatement with the request.chgcat.sym is being built even though the
condition is not satisfied!! Whats wrong??? i even tried changing the
statement sot if and elseif but it doesnt work...is that the right code?
there is no syntax errors within vba and that statement sounds totally
logical..
acts as a seach filter for a set of data. All criteria are optional so the
user can select any criteria he wants. The problem is i'm not capturing the
user input correctly...this is what i use:
'if combo box priority is not empty, capture user input
If Not IsNull(Me.cbx_priority.Value) Then
sqlmainstring = sqlmainstring & " AND request.chg.priority = " & quot
& Me.cbx_priority.Value & quot
End If
'if combo box prod category is not empty, capture user input
If Not IsNull(Me.cbx_prod_cat.Value) Then
sqlmainstring = sqlmainstring & " AND request.chgcat.sym = " & quot &
Me.cbx_prod_cat.Value & quot
End If
If IsNull(Me.cbx_priority.Value) And IsNull(Me.cbx_prod_cat.Value) Then
MsgBox ("You have not entered any criteria, please do so before
searching")
End If
sqlmainstring = sqlmainstring & " ORDER BY request.chg.id DESC "
mainqdf.Sql = sqlmainstring
set mainqdf = nothing
of course before all these is the main sql statemetn with the SELECT, FROM
and WHERE statements.
all these are under the on_click portion of a command button. Right now if i
leave the whole form blank, the msgbox doesnt appear!! instead the
sqlstatement with the request.chgcat.sym is being built even though the
condition is not satisfied!! Whats wrong??? i even tried changing the
statement sot if and elseif but it doesnt work...is that the right code?
there is no syntax errors within vba and that statement sounds totally
logical..