select specific records in forms- Help!

jenny_gurl

jenny_gurl
Local time
Today, 19:01
Joined
Oct 10, 2005
Messages
23
Hello,

I'm sure this has a simple solution, but iv searched this forum and every solution that i get is filled with code that goes over my head! Well here goes...

I have a main form called expense... which contains a tab control. the tabcontrol in turn has three pages containing a subform each. (lets call them sbfrm1 sbfrm2 and sbrm3.)
All three subforms are based on three different queries (say Qry1 Qry2 and Qry3) but the three queries are based on the same table. this table contains all the expenses incurred over the months across three categories (hence three queries). the subforms are to display these expenses according to categories.. i.e. sbfrm1 displays records pertaining to Category1, sbfrm2 for category2 etc.(the queries ensure that!)

when the main form opens, the subforms display all the records in the table according to category...but not according to the month in which the expenditure was incurred.

I now want to add a feature that enables the user to choose records pertaining to a given month at the click of a button.

for eg. if there is an option group named month, (with toggle buttons as the month names), then if the user selects the month Aug, then immediately the subform1 displays records under category1 for the month Aug? However I want to include an "ALL" option as well whereby all the records are displayed for all months (the category criteria must be maintained at any cost!!!!
Is there a solution that will not use too much code!

Thanks in advance.
 
Jenny:

Have you considered using a combo box with the months in it rather than toggle buttons? It would occupy far less space on your screen.

You can put the code in the "AfterUpdate" event that says something like:

me.Form.Filter = "month = forms!frmMyForm!cboMonthFilter" or something.

then

Me.Form.FilterOn = True

I'm not sure how your dates are stores, so you may need to play with the filter to have it determine the month of each date.

You can also have a special case if "<All>" is checked where the filter does not get applied.

Let us know how you do.

SHADOW
 
hi shadow,

thanks for you reply!
i'l definitely try that out!
 
Hello Shadow,

I tried putting combo boxes and stuff but the trouble is that the combo box is on the main form. even if i try to apply some sort of a filter in the after update event it doesnt apply to the three subforms! Is there any particular way to refer to a subform.

I was checking up some stuff about this and i stumbled upon applying a filter using a macro.. it says the same thng about running the macro in the after update event of the control (combo box etc). but somehow my filter fails to work!
 
Jenny:

The trick here is to be able to reference the subform.

You can look in the Access Help file for this, and there have been many posts about it, but in general, consider a subform to be a control on a main form, and THEN reference the subform.

For example:

Forms!frmMain!frmSub1.form.Filter = "Blah blah blah"

Get it?

If worse comes to worse, upload your file here and me or someone else will give you a hand in referencing your subs

SHADOW

(P.S. Don't use "blah blah blah" as a REAL filter...it probably won't work!)

;)
 
hi shadow,

I'l try that out and let you know. thanks again!!!
 

Users who are viewing this thread

Back
Top Bottom