Full Version: Changing sub-forms on the same form
UtterAccess Forums > Microsoft® Access > Access Forms
carter1
Is it possible to change which subform is displayed by pressing a button, on the same form?

Each subform is based on a parameter query, so it needs to open the type-in-box as usual.

By the way, I'm a newbie and don't really understand VB. Directions would be helpful (e.g. found in tools->options etc)


My first post! Yay.
Edited by: carter1 on Thu Dec 29 15:11:35 EST 2005.
freakazeud
Hi,
welcome to UA forums.
I'm not exactly sure what your set up is like and why you want to do that, but may I suggest a tab control?
You can add all the different subforms on different tab pages in your tab control and then you can achieve what you want I think.
Maybe you can clarify a little more though about what you want to achieve and why.
HTH
Good luck
fkegley
Yes, that can be done, but it will require code.

Open the form in design view, if you haven't already put a command button on the form, cancel the wizard. Then right-click the command button and click properties in the list. Click the Event page, the On Click, the ... at the right end, the Code Builder choice, OK. The code window should open, and you should be in the right place to type:

Me.[NameOfSubformControl].[SourceObject] = "NameOfForm"

If the form is based on a parameter query, then that box should appear, type in the values, the subform control should then display the correct form and records.

EDIT: freakazeud's solution will be easier to implement
Edited by: fkegley on Thu Dec 29 15:16:50 EST 2005.
carter1
Hi.
Am building a library database search. It is like this:
http://norlink.norfolk.gov.uk/cgi-bin/vps2...ssion_no=829640
Im after the links like "author" and "title" to stay put, which is why I was thinking of subforms that change depending on which button you click.
What do you think?
freakazeud
Ah...ok!
I think I would go with the tab control solution. This way you have everything in front of you and just need to switch tabs depending on what selection was made.
You might find useful information here and I'm sure there are many examples here on UA as well if you search.
HTH
Good luck
carter1
How do I find the name of the "subform control" ?
I was really after parameter queries for this but - although tabbed are perfect for another bit - thanks!
freakazeud
>What do you mean? The name is whatever you called it!
carter1
EDIT:

Me.[NameOfSubformControl].[SourceObject] = "NameOfForm"

"Name of form" = name of the form

"NameOfSubformControl" = Name of the subform


ok I think thats right
Edited by: carter1 on Thu Dec 29 15:35:37 EST 2005.
carter1
I hadn't actually created the subform... now I have

But now it runs every time I go from design view to form view.

Oneed it to run when I click the button...
freakazeud
Oh...so you are using Franks solution! That is not the tab control one, but if you want it...!
If you double click on the black border of the subform control in design view it should open its property window. Go to the other tab and check its name.
That is the name you want to use:
e.TheNameYouJustFound = "TheOtherForm'sNameYouWantToShow"
HTH
Good luck
carter1
I think the problem lies within using parameter queries.
Oonly want the box to appear after I click the button, and then for it to display the results in the subform.
oes this help or change anything?
blush.gifR:
My code is wrong
Me.[sf_search_author].[SourceObject] = form_searchby
name of subform.......................... = name of the form the button is on
carter1
p.s. I do need the subform in the form first?
But then it runs straight away...
freakazeud
Hi,
Oreally don't know what you are doing there. Maybe you can attach a stripped down version of your db to a reply or a screen shot so we can look at it.
I don't think it has anything to do with parameter queries. I don't know why and what you are using these for either.
HTH
Good luck
carter1
Here it is attached stripped down.
RowleyD
I have a question along the same lines. Is it possible to have a subform pop up instead of being imbedded in the parent form?
hould this be a new thread? I'm not 100% familiar with board etiquette.
RowleyD
Actually, I think that carter1 and I are looking at similar issues.
arter1, you want a form to open based on data in the parent form?
If you use a parameter query, then it isn't a true subform. Subforms are based on the relationship between tables.
Sorry if I am telling you something you already know.
fkegley
Yes, if you use the form wizard, it will ask if you want subform or linked form. Just tell it linked form and it will put a button on the main form that opens the subform in its own window.
There are other ways as well to do it.
It should have been in its own thread because technically it was not dealing with the original post. Also you will get more responses if you post in its own thread.
I was looking at my responses and saw yours so I have responded.
carter1
Has anyone clicked the attachment???
I want to have several buttons each running a parameter query, which then shows the results on the same form.
So clicking a different button will replace where the other query was.

Please help!
fkegley
carter1, is this what you are looking for?
carter1
Erm..... YES.
Thanks!
fkegley
You're welcome, carter1. I am glad I was able to help.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.