Requery Subform (Filter?)

  • Thread starter Thread starter Neil M
  • Start date Start date
N

Neil M

How do I requery a subform within a form

MAIN > MAINSUB (sub)


I have a pulldown list for filtering the records but I want to know how to
change the subform query it uses on the selection of the boxes or all of the
boxes (like a filter?)

Is a filter the best way to do this or via the comboboxes linked to
different queries?

Thanks,


Neil
 
First Question:
Me.MySubformName.Requery

I don't quite understand the other two questions.
 
lovely thanks that works
but my main reason was this setup;


I have a form (MAINFORM) and within this is my datasheet subform (MAINSUB)

I have Name, Number and Address (unbound) at the top as pulldown lists which
link to the appropriate tables
I want to query the subform so that if I select a name and/or address (area)
and/or number it queries/filters the subform below.

I can't seem to get this working and also everytime i query the subform it
adds a new blank record to the database.

can you help please?
 
actually i think i missed an important note out;

I need the comboboxes to filter different queries - i do not need to filter
by name AND number.
Either name or number changes the filter dependent on the complete database
and not just the subform query

Hope this makes sense.

i need to select the different combobox
 
How is your subform filtering set up? If you change queries in your main
form, it may be affecting how the subform is working.
 
well.. heres the update after a day of playing about with the code, etc..

I have the main form with the 3 comboboxes at the top.
I have decided to link all to a query which changes the subform correctly
(ALTHOUGH STILL ADDS A NEW BLANK RECORD WHEN REFRESHING THE SUBFORM)

My next problem is how do I create the <ALL> at the top of each subform.
I have read up on how to do it, something about a UNION Query but I can't
seem to get the coding right?>
Cany anyone help on this or any of the other problems please.

Thanks,

Neil
 
ooo also forgot - i need to remove the duplciate records from the combo box
as well? so it only displays the name rather than the field.

eg: Name field - Name1, Name1, Name2, Name3, Name4, Name3
I want to display: <All>, Name1, Name2, Name3, etc
 
Here is the best info on adding all:

http://www.mvps.org/access/forms/frm0043.htm

Now as to your duplicates and using the above info, post the code for the
combo's row source and we will see if we can help with that.

The adding a new record part I am not sure of. Is it just a blank record
like if you open a table in datasheet view?
 
the code im using is the following; (to add ALL to my combo box)

SELECT DISTINCTROW TBL_Issues.Learner, TBL_Issues.[Learner2] FROM TBL_Issues
UNION SELECT "<ALL>","" FROM TBL_Issues
ORDER BY TBL_Issues.Learner;
 
Back
Top