Is this possible, how to go about it

G

Guest

I am just trying to see if this is possible before I waste anytime.

I have a search form for searching for courses, but I would also like to be
able to have the option to search all courses, or only future courses.

The form has a continous subform that displays the results as you type. the
subform is based on a query which gives all of the courses in the database.
to search for future courses I the query needs to be changed to add in the
table tblcoursedates.

If I used an option group to select between all courses or future dates can
I change the query the subform is based on? Do I need to have two subforms
and the option gp makes one visible etc.

sorry I know what I want but cannot get there

thanks

Phil
 
D

Douglas J. Steele

To change the query being used as the recordsource for the subform from code
in the parent form, use:

Me!NameOfSubformControl.Form.RecordSource = "QueryName"

It's possible (although I doubt it) that you'll also have to do a Requery:

Me!NameOfSubformControl.Form.Requery

Note that depending on how the form was added to the parent form as a
subform, the name of the Subform control on the parent form may not be the
same as the name of the form being used as a subform.
 
G

Guest

Hi Phil

I would include the date info in the subform query all the time and alter
the subforms filter depending on the user selection...

Me.[ChildForm].Form.Filter = "CourseDate > date()"
Me.[ChildForm].Form.FilterOn = True

and
Me.[ChildForm].Form.Filter = ""
Me.[ChildForm].Form.FilterOn = True


If you are already using the filter and it depends on other controls then
you will need to build the filter from scratch each time by checking each
control in turn.

Hope this helps

Regards

Andy Hull
 
G

Guest

Hi Andy

thanks for your reply, that is how I did it on my previous course database,
however this one is different in that some courses do not have start dates or
end dates and therefore no corresponding record in the table, whereas others
have many. if I add the table to the query it only show the courses which
have an entry in the table. so cannot do it this way this time

thanks again

Phil

Andy Hull said:
Hi Phil

I would include the date info in the subform query all the time and alter
the subforms filter depending on the user selection...

Me.[ChildForm].Form.Filter = "CourseDate > date()"
Me.[ChildForm].Form.FilterOn = True

and
Me.[ChildForm].Form.Filter = ""
Me.[ChildForm].Form.FilterOn = True


If you are already using the filter and it depends on other controls then
you will need to build the filter from scratch each time by checking each
control in turn.

Hope this helps

Regards

Andy Hull


Phil said:
I am just trying to see if this is possible before I waste anytime.

I have a search form for searching for courses, but I would also like to be
able to have the option to search all courses, or only future courses.

The form has a continous subform that displays the results as you type. the
subform is based on a query which gives all of the courses in the database.
to search for future courses I the query needs to be changed to add in the
table tblcoursedates.

If I used an option group to select between all courses or future dates can
I change the query the subform is based on? Do I need to have two subforms
and the option gp makes one visible etc.

sorry I know what I want but cannot get there

thanks

Phil
 

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