ComboBox + Like

M

mattia

Hi all, I have a combo box tha I use to select an ID field. The query is
simply: SELECT ID FROM MyTable WHERE ID = [Forms]![MyMask]![cboID].
Obviously at the beginning cboID is NULL so I have nothing to show. Now,
I want that this situation (nothing choose) can let me show *everything*
so WHERE ID = LIKE "*". I've tried to use this function:
IIF(IsNull([Forms]![MyMask]![cboID]; LIKE "*"; [Forms]![MyMask]![cboID])
but nothing happens... any suggestions?

Thanks, Mattia
 
J

Jeff Boyce

Mattia

If you load up your form with everything (because nothing was selected),
that could take some time and be a 'drain' on the network.

If you'll describe a bit more specifically what having all the records
loaded into the form will allow you/your users to do, folks here may be able
to offer more specific suggestions.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Also, if you are only selecting the ID from your table after first selecting
the ID in the combobox, why bother?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

mattia

Il Fri, 17 Jul 2009 16:39:53 -0700, Jeff Boyce ha scritto:
Also, if you are only selecting the ID from your table after first
selecting the ID in the combobox, why bother?

Regards

Jeff Boyce
Microsoft Office/Access MVP

mattia said:
Hi all, I have a combo box tha I use to select an ID field. The query
is simply: SELECT ID FROM MyTable WHERE ID = [Forms]![MyMask]![cboID].
Obviously at the beginning cboID is NULL so I have nothing to show.
Now, I want that this situation (nothing choose) can let me show
*everything* so WHERE ID = LIKE "*". I've tried to use this function:
IIF(IsNull([Forms]![MyMask]![cboID]; LIKE "*";
[Forms]![MyMask]![cboID]) but nothing happens... any suggestions?

Thanks, Mattia

Well, ok, I provided a partial example. Suppose I have 3 combo boxes and
a table with the fields Val1, Val2, Val3. If the user select nothing, I
just show the entire table. Then, if the user selects one or more
combobox I show the table based on some criteria. Essentially the
comboboxes permit to combine different criteria.

Suppose I have a table like: Product, Vendor, Client. The first combobox
is associated with Product, the second with Vendor etc. Now I want to
choose all the possible combination in order to view my table. E.g.
Select Product = 1 and Client = 3, Slelect Product = 2, Select Vendor = 5
etc. A comboboc not selected gives me NULL as a result, so if every combo
box is not selected I have no result. Am I correct?
 
J

John W. Vinson

Hi all, I have a combo box tha I use to select an ID field. The query is
simply: SELECT ID FROM MyTable WHERE ID = [Forms]![MyMask]![cboID].
Obviously at the beginning cboID is NULL so I have nothing to show. Now,
I want that this situation (nothing choose) can let me show *everything*
so WHERE ID = LIKE "*". I've tried to use this function:
IIF(IsNull([Forms]![MyMask]![cboID]; LIKE "*"; [Forms]![MyMask]![cboID])
but nothing happens... any suggestions?

Thanks, Mattia

You cannot pass an operator such as LIKE in a parameter - only an actual
value. Try a different approach: use a criterion of

=[Forms]![MyMask]![cboID] OR [Forms]![MyMask]![cboID] IS NULL

Leaving the combo empty will trigger the second clause and retrieve all
records.
 
M

mattia

Il Sat, 18 Jul 2009 00:03:55 -0600, John W. Vinson ha scritto:
Hi all, I have a combo box tha I use to select an ID field. The query is
simply: SELECT ID FROM MyTable WHERE ID = [Forms]![MyMask]![cboID].
Obviously at the beginning cboID is NULL so I have nothing to show. Now,
I want that this situation (nothing choose) can let me show *everything*
so WHERE ID = LIKE "*". I've tried to use this function:
IIF(IsNull([Forms]![MyMask]![cboID]; LIKE "*"; [Forms]![MyMask]![cboID])
but nothing happens... any suggestions?

Thanks, Mattia

You cannot pass an operator such as LIKE in a parameter - only an actual
value. Try a different approach: use a criterion of

=[Forms]![MyMask]![cboID] OR [Forms]![MyMask]![cboID] IS NULL

Leaving the combo empty will trigger the second clause and retrieve all
records.

This is exactly what I needed. Thank you.
 

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