Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me need to be done asap

Status
Not open for further replies.

SAM453

Programmer
Jun 6, 2011
18
US
I am using sql server has a back end. I have a command button and 5 combo boxes.

When a user click on a command button then it should look for the any values entered in any combo box.
Basically the back end sql select statement will be haivng where clause with all these combo boxes values has filters.

If the user selects the value in 2 - 3 combo boxes then by back end sql select statement should be using AND condition.If the user doesn't select any value in combo box then it should display simple select * statement.

Basically the back end sql select would be
if any combo box has value then it should have select * from ... where column name = combo.value
if combo box value is "" then
select * from table name...

I hope it is clear.

Thanks,

Sam.


 
Why double-post?

If you want to determine if a combobox has any values selected then we can test for the opposite condition - if it is empty.

Here's a small snippet of code I put together that might be of interest to you.

Code:
im ctl As Control
Dim blnEmpty As Boolean

For Each ctl In Me.Controls
    If ctl.ControlType = acComboBox Then
    ctl.SetFocus
        If ctl.Text = "" Then
            blnEmpty = True
        End If
    End If
Next

If blnEmpty = True Then
    'None of the comboboxes have been selected
Else
    'One of the comboboxes have a value selected
End If

Disclaimer: I put this together in about 10 minutes flat, I don't expect it to work 100% but I think it's pretty close to what you need so feel free to modify it to fit your needs.
 
Oops, the first line in the above code was supposed to be:

Code:
Dim ctl As Control

Somebody really aughta install an edit button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top