Re: Using combo box selection to supply criteria for query

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Try first assigning the value from your combo box to a variable. I realize
that I will work using just the reference to the control, but when you
already have an issue with the correct syntax it makes it a little simpler to
just declare a variable and assign the value from the combo box to it.

dim strRegion as String

strRegion = [Forms]![Main Form]![Region Select]

then use the variable in your sql statement as:

Like """ & strRegion & "*""


Later if you want to come back and just use the reference to the control,
you still can do that.
-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm


"Erick C" wrote:

No luck.
I even tried putting the wildcard on both ends and it still did not
work:
Like "*" & [Forms]![Main Form]![Region Select] & "*"
and I tried:
Like [Forms]![Main Form]![Region Select] & "*"

And the Region is only a one letter designation coming from the select
query, so there is not a lot of stuff that is being brought into the
combo box, just single letters.


On Sep 16, 2:52 pm, KARL DEWEY <KARLDE...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Try this --
Like [Forms]![YourFormName]![Combo22] & "*"

If nothing is selected in the combo then it is the same as selecing all.

--
Build a little, test a little.



"Erick C" wrote:
I am hoping someone can help me out with a problem that I am having.
I am setting up a database that will serve as an archive for our
reporting results. I am jsut starting to get everything together, so
I can modify anything if necessary. I made a form that has six
different combo boxes along the top. The data sources for the combo
boxes are different, some have names that I manually added. Other
boxes use select queries that I set up pulling data from certain
tables as data sources, since using the tables themselves yielded
duplicate results (the same region is listed multiple times in one
table).

In the end I want to set up buttons for various reports, and the
results will be driven by the combo box selections made on the forms.
I tried setting up a test select query, and it works for the most
part. 5 out of the 6 combo boxes will yield results if they are
selected by themselves, but one combo box will only filter the query
results when it is used in conjunction with another combo box.

It was pretty messed up setting up the query, since I had to set up a
line of criteria for each possible combination that the combo boxes
could be selected, or not selected, meaning I have 32 rows of
criteria. I can post my SQL view, but it is around 3 pages long whan
I copy it to Word

Any help I can get, or any suggestions on how I can set up my filters
so they will work better, more efficiently, I would be very grateful.

Erick- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • Re: Dynamically changing font size of combo box
    ... That's exactly what I do have - a reference to the control. ... > Dim myCBX As OLEObject ... >> I have a spreadsheet that creates a number of combo boxes based on info ...
    (microsoft.public.excel.programming)
  • Re: If Statement
    ... you have to repeat the reference to the ... control each time: ... Or in this situation doesn't make sense: ALL selections would pass the ... following statement and I'm getting a Type Mismatch error. ...
    (microsoft.public.access.forms)
  • Re: hide combo box
    ... do you mean a control from the Forms toolbar or do you mean a control located on a display UserForm? ... describe "based on selections" for us in more detail. ... Do you mean cell selection, changing values in cells, selections made from the combo boxes, something else? ...
    (microsoft.public.excel.misc)
  • Moving grouped controls
    ... If I group several text boxes and an image together, is there a way via VBA ... to move everything at once (reference the group) rather than have a line of ... code for each control? ...
    (comp.databases.ms-access)
  • RE: Counting results of "yes" check boxes and combo box selections
    ... selections and never more than 2, you can use two text boxes with control ... However within the Report Footer i would like to ...
    (microsoft.public.access.reports)