Full Version: Is it Possible to Alter Closed Form w/VBA?
UtterAccess Forums > Microsoft® Access > Access Forms
yosemitegurl
I would like to be able to change the source object of a subform on a form that is not currently open. Is this possible? If so, how?
Thank you Access geniuses!
Jack Cowley
I have never tried to do this, but as I recall you have to open the form in design mode, make the change and then close it all with code (which you certainly can do). Instead of that can you change the Source Object when you open your main form based on what or how you open the form? I mean that if you open the form from FormA that you check which form opened it and if it was FormA then you change the Source Object else you don't...
hope that I am making some kind of sense!!!
Jack
yosemitegurl
Interesting ... How can you open a form in design mode using Code?
Jack Cowley
DoCmd.OpenForm "FormNameHere", acDesign
Below are the arguments for the OpenForm method...
OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
Search Access help for OpenForm to see all the constants used with each argument. Or you can place the cursor in the word OpenForm on you code page and press F1 to see the details of the OpenForm method....
hth,
Jack
Aquadevel
Jack,
You da man!!!
sad.gif
Jack Cowley
Aqua -
Thank you! Sometimes I get lucky and get it right...
Jack
vtd
It may be a lot easier if you leave the SourceObject Property of the SubformControl empty in the Design View of the main Form and use VBA code to assign the SourceObject to the SubformControl on the Open (or Load) Event of the main Form.
ChrisO
Also bear in mind that a Form can’t be opened in design mode in an MDE file.
egards,
Chris.
Jack Cowley
Chris -
xcellent point! Thanks for pointing that out...
Otrust the water restrictions will be lifted soon so you can take a shower more often than once a month....or was it once a week? wink.gif Aussie rules can be so tough...
Jack
ChrisO
G’day Jack.
Brisbane’s water supply is still only around 38% but with the rain we have been having lately it is improving.
Should drink more wine to conserve water. o!
Kind regards,
Chris.
yosemitegurl
I appreciate the help.
I have a weird way of doing my forms that I use to try to make my app look more like a windows application. I have a main form for each "module" in my app with a menu across the top. When you click a different menu item, the subform source object changes as applicable. This way, the app fills the entire window and all the menu levels are always visible. If there is a different way to do this ... it's too late anyway ... I have several 100 thousand lines of code already. This is an app that has evolved over the past 4 years and I am self-taught so ....
The problem is that while I am doing development, if I get a debug error, sometimes I inadvertently save the main form with a subform source object that is not the one I want to start with initially. Sometimes this causes a problem because some different subforms have different link characteristics that don't apply to others.
So I would like to be able to put an invisible (to everyone but me) button on my main form to reset all the starting subforms programmatically before I mde my front end and before I send it out ... without having to check each form individually.
The info you've given me will do exactly what I need. Thank you so much!
Karen
Jack Cowley
Karen -
HEW! You have quite a project going and it sounds like you have done an excellent job!!! Congratulations and we are glad that we could help in some small way...
Jack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.