nightmare search

  • Thread starter Thread starter bleep
  • Start date Start date
B

bleep

Hi i'm new to access and am totally confused with searches. I have a
form the has a subform contained in it. The main form has a number of
combo boxes on it. i need to be able to select a value in one of the 10
combo boxes on my form click a search button and then filter the data
according to the value selected. I've tried using queries and they dont
seem to work i dont know any visual basic so am really struggling with
this. would anyone be able to help me please?
Thanks
Faye
 
Faye,

Do you mean that each of the 10 comboboxes is for entry of a criteria
for each of 10 corresponding fields in your query? But you will only
ever want to enter criteria for one of them at any given time? Maybe an
example would help to know what you are doing.
 
First, you can right click on a field and choose Filter by
Selection. Below I describe a button for removing the
filter, or you can do so from the toolbar. It depends on
who will be using the database.
With much help from this group, I came up with a form-
based solution to a similar problem (assuming I understand
you correctly). I used unbound combo boxes for the search
rather than using cotrols that are bound to a source in
the table or query. For instance, I placed in the form
header an unbound combo box (cboLookupSubject) to look up
the value in the field [Subject] in the form Detail
section. In the combo box's After Update event I placed
the following code:
DoCmd.ApplyFilter , "[Subject]='" & cboLookupSubject & "'"
[Subject] is a text field; I believe the code for a number
field would be:
DoCmd.ApplyFilter , "[Subject]= " & cboLookupSubject
Do the same for the rest of your fields. I put the combo
boxes in the header, and made the header invisible. A
command button on the form makes the header visible when I
want to conduct a search.
The row source for the combo box is a query. With the
combo box selected in design view, right click and select
Properties. This opens what is known as the Property
Sheet. Click the Data tab, and click Row Source. Click
the three dots on the right side of the row. Select the
table from the list, click Add, then Close. Double click
Subject (to use my example) in the top part of the
window. In the grid, click Sort and choose ascending. If
you have the same words in [Subject] for many records,
right click the top part (next to, not in, the table),
click Properties, and set Unique Values to Yes. Close the
window, and save when prompted. You can click Save and
give the query a name, if you like.
Similarly, when I say that code needs to go in the After
Update event, select the combo box and open the property
sheet. At the event tab, click After Update, click the
three dots, click Code Builder, then OK. Insert the code
at the blinking cursor.
You might want to put a button on the form, with its Click
event set to: Me.FilterOn = False. This will let you see
all of the records again after you have filtered them.
The combo box wizard might help. Make sure the magic wand
in the toolbox is highlighted, then click combo box, then
click the form and follow the prompts.
 
Back
Top