Query Formula

  • Thread starter Thread starter George
  • Start date Start date
G

George

I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a pop-
up message letting them know they didn't make a selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks
 
I assume that you run the query by clicking a button on the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo box."
Else
' run the query using your code
End If
End Sub
 
Based on what you wrote it sounds like I add this to the
button they click to run the query - I will give it a try.
There is one situation where they have to make a selection
from two combo boxes to run the query - how can I modify
this to look at two combo boxes prior to running query.

Thanks - George
-----Original Message-----
I assume that you run the query by clicking a button on the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo box."
Else
' run the query using your code
End If
End Sub


--
Ken Snell
<MS ACCESS MVP>

George said:
I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a pop-
up message letting them know they didn't make a selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks


.
 
When the user clicks the forms button it runs a Macro
which runs the query - is there a way to tweek the query
statement to look to make sure a selection was made in the
combo box and if not pop-up a message no selection made.

thanks
-----Original Message-----
I assume that you run the query by clicking a button on the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo box."
Else
' run the query using your code
End If
End Sub


--
Ken Snell
<MS ACCESS MVP>

George said:
I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a pop-
up message letting them know they didn't make a selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks


.
 
Using a macro, you can have these steps as the first two steps in the macro
that is run by clicking the button:

Condition: Len(Forms!FormName!cboBoxName & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box.

Condition: . . .
Action: StopMacro


If you want a selection to be made in both combo boxes:

Condition: Len(Forms!FormName!cboBoxName1 & "") = 0 Or
Len(Forms!FormName!cboBoxName2 & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box(es).

Condition: . . .
Action: StopMacro

--
Ken Snell
<MS ACCESS MVP>

George said:
When the user clicks the forms button it runs a Macro
which runs the query - is there a way to tweek the query
statement to look to make sure a selection was made in the
combo box and if not pop-up a message no selection made.

thanks
-----Original Message-----
I assume that you run the query by clicking a button on the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo box."
Else
' run the query using your code
End If
End Sub


--
Ken Snell
<MS ACCESS MVP>

George said:
I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a pop-
up message letting them know they didn't make a selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks


.
 
Wow - You hit the nail on the head - Thank You !!!
-----Original Message-----
Using a macro, you can have these steps as the first two steps in the macro
that is run by clicking the button:

Condition: Len(Forms!FormName!cboBoxName & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box.

Condition: . . .
Action: StopMacro


If you want a selection to be made in both combo boxes:

Condition: Len(Forms!FormName!cboBoxName1 & "") = 0 Or
Len(Forms!FormName!cboBoxName2 & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box (es).

Condition: . . .
Action: StopMacro

--
Ken Snell
<MS ACCESS MVP>

George said:
When the user clicks the forms button it runs a Macro
which runs the query - is there a way to tweek the query
statement to look to make sure a selection was made in the
combo box and if not pop-up a message no selection made.

thanks
-----Original Message-----
I assume that you run the query by clicking a button on the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo box."
Else
' run the query using your code
End If
End Sub


--
Ken Snell
<MS ACCESS MVP>

I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a pop-
up message letting them know they didn't make a selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks


.


.
 
You're welcome.

George said:
Wow - You hit the nail on the head - Thank You !!!
-----Original Message-----
Using a macro, you can have these steps as the first two steps in the macro
that is run by clicking the button:

Condition: Len(Forms!FormName!cboBoxName & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box.

Condition: . . .
Action: StopMacro


If you want a selection to be made in both combo boxes:

Condition: Len(Forms!FormName!cboBoxName1 & "") = 0 Or
Len(Forms!FormName!cboBoxName2 & "") = 0
Action: MsgBox
Message: You must choose a value in the combo box (es).

Condition: . . .
Action: StopMacro

--
Ken Snell
<MS ACCESS MVP>

George said:
When the user clicks the forms button it runs a Macro
which runs the query - is there a way to tweek the query
statement to look to make sure a selection was made in the
combo box and if not pop-up a message no selection made.

thanks

-----Original Message-----
I assume that you run the query by clicking a button on
the form? Do a
validation on the value of the combo box in that code:

Private Sub cmdButtonName_Click()
If Len(Me.cboBoxName & "") = 0 Then
MsgBox "You must make a selection in the combo
box."
Else
' run the query using your code
End If
End Sub


--
Ken Snell
<MS ACCESS MVP>

I have a Query and its search is based on a combo box
selection thats in a form. It works but if the user
fails
to make a selection the results is a blank report. What
can I add to the query search statement that if the user
doesn't select an Item from the combo box they get a
pop-
up message letting them know they didn't make a
selection.
Here is the query criteria I am using

Like [Forms]![F-Print-Options]![Combo6]

Thanks


.


.
 
Back
Top