Forms and Subforms Loading and Unloading

MarkL

Registered User.
Local time
Today, 01:22
Joined
Dec 16, 2009
Messages
12
I am learning Access, using Access 2000. I created a database to have a Main Menu form (which has a picture for the background showing command button background pictures for places where I have command buttons) with command buttons (transparent) on the form that open other forms and closes the Main Menu form (instead of hiding/unhiding because of memory and performance considerations). The picture for the background on the other form is same as the Main Menu except without the command button background pictures. On that form are command buttons (visible): OK command button (if changing/editing record data) which saves the data, closes that form, and reopens the Main Menu form; Cancel command button, which does Me.Undo, closes form, and reopens Main Menu form. However, there is a horrible flickering and background image flickering, which varies upon switching from page to page, and even when Main Menu reopens.

I then thought to use one Main Form (one background, etc.) with load and unload Subforms (Main Menu Subform, etc.) so there is a seemless central change on the Main Form. However, I cannot figure how when the Subform is opened to then use the command buttons on the Subform to do the operations above (OK/saved, Cancel), but instead of opening and closing forms, to unload that Subform from the Main Form and reopen the Main Menu Subform on the Main Form. Thanks for any help to accomplish this.
 
Hi everyone,

While there were a good many views of my issue, there was no reply; which is OK because being a novice I am not sure I explained it adequately perhaps. Anyway, a friend of mine who knows Access and VBA a whole lot more than me, came up with the solution. For a command button's On Click (Event Procedure) using the following coding unloads one SubForm and loads the desired SubForm into the SubForm area on the Main Form.

Me.Parent.[Name of SubForm area on Parent].SourceObject = "[Name of SubForm to be loaded]"

As I am new to Access and learning, I hope I've used correct terminology. If not, sorry. Also, from what I have seen most use subform or Subform, but I prefer SubForm.

For further info, I use the Top Menu Bar to designate with the Caption what is open currently. There was no problem when I was switching forms as each form had its own Caption. However, after switching to using SubForms loading and unloading, the Caption remained Main Menu. I researched in the Forum here to see if there was coding to change the Caption on the Main Form to match a SubForm's Caption, and there was a thread on how to change a label's Caption in another form/subform. I used that coding in On Open for each SubForm modified to refer only to the Main Form (i.e., no label designation), and it worked!

Forms![Main Form name].Caption = "[Caption of SubForm]"

To ensure when switching back to the Main Form's primary SubForm (mine is Main Menu) that its Caption is displayed, for the Main Form's primary SubForm for On Open insert same coding using the Caption of the Main Form's primary SubForm, or else the Main Form displays the last SubForm's Caption (using Access 2000, not tested in other versions).



Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom