change form displayed in subform depending on user input

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form displays search results in a subform. depending on which search
criteria the user has selected a different query is run. i have these
queries on seperate forms. is it possible to change which form is displayed
in the subform based on the users selection.

many thanks
 
You can change the Recordsource property of a single subform, or change the
SourceObject property to multiple subforms. Use the Recordsource property if
the queries are based on the same tables and have the same fields, and use
the SourceObject property if they are different subforms. A subform is a
control on a form, like a textbox, so the code to change it looks like:

Recordsource:
Me.SubformControlName.Form.Recordsource = "qryWhatever"

SourceObject:
Me.SubformControlName.SourceObject = "frmSubFormName"
 
Arvin Meyer said:
You can change the Recordsource property of a single subform, or change the
SourceObject property to multiple subforms. Use the Recordsource property if
the queries are based on the same tables and have the same fields, and use
the SourceObject property if they are different subforms. A subform is a
control on a form, like a textbox, so the code to change it looks like:

Recordsource:
Me.SubformControlName.Form.Recordsource = "qryWhatever"

SourceObject:
Me.SubformControlName.SourceObject = "frmSubFormName"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com




Hi I'm trying to do basically the same thing. On one form I've titled it "Delete Record". In a subform I have two fields called "Header" {Delete Record}. The other is a memo field with instructions to delete a record. What I need is to have the sub form display the information of the Delete Record form in the sub form. The sub form is used as a help box so I'll be using it on different forms. So I guess what I'm saying is that the Delete Record form will searches the table where the instructions are located and have them displayed in the sub form.
 

Thanks Arvin for the quick reply. Can I just look in the tbl_information
table or do I need to do a query? I'f I have to do a query can I create one
on the fly so I don't have to create abunch of querys?

Thanks
 
Hi. I tried using this code but keep getting errors. Is it different for
Access2007? I have a main form that I want to show different subforms
depending on which option is shown (has been previously filled) in a
particular main form field. There are 4 different options which should open
subforms based on different tables depending on the selection and I am
putting the code in the form's "on current" property

Many thanks

Leonie
 
Back
Top