Combo Box


G

Guest

I have a combo box named cboProducts based on a sql rowsource:

SELECT tblProductGroup.ProdGdr
FROM tblProductGroup
GROUP BY tblProductGroup.ProdGdr;

there is a command button on the form that uses the contects of the selected
combo box as criteria to perform file operation. The button is named: cmdOk.
The ON CLICK event contains this:

strSQL = "UPDATE tblProductGroup SET tblProductGroup.Description = ""New
Image"" " _
& "WHERE (((tblProductGroup.ProdGdr)=" & Me.cboProducts &
"));"
DoCmd.RunSQL strSQL

I need to have the ability to perform those file operations on ALL products,
not just those available in the sql statement of the combobox. I need to be
able to select "ALL" in the combobox. How do I do this without changing the
row source type of my combobox into a value list?

thanks in advance
 
Ad

Advertisements

G

Guest

I assume you want to update all the records incase there is no value selected
in the combo.
In that case try this
strSQL = "UPDATE tblProductGroup SET tblProductGroup.Description = ""New
Image"" " _
& "WHERE tblProductGroup.ProdGdr Like " & nz(Me.cboProducts,'*')

DoCmd.RunSQL strSQL

Back up before you try
 
Ad

Advertisements

S

Steve Schapel

Faberk,

Make the combobox's Row Source like this...

SELECT ' - All -' As ProdGdr
FROM tblProductGroup
UNION SELECT DISTINCT ProdGdr
FROM tblProductGroup
ORDER BY ProdGdr

Do your code like this...

strSQL = "UPDATE tblProductGroup SET Description = 'New Image'"
If Me.cboProducts <> " - All-" Then
strSQL = strSQL & " WHERE ProdGdr = " & Me.cboProducts
End If
DoCmd.RunSQL strSQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top