rjpatrick
Oct 24 2007, 08:36 AM
Hi guys, hope everyone is ok!!!
Hoping you can help me with this little problem i have?
I have loads of forms that are all linked ie there is a welcome screen and this has a button that allows me to go to tha attendance form. I use a simple macro to close the welcome screen and open the attendance form.
the whole database has loads of cases where this happens.
The problem i have is, i am using pop up forms and it just doesn't look very good, with the form changing positions on the screen and there is a clear jump when a form is closed and a new one is opend.
My suggestion for getting rid of this problem would be to create 1 form and have a central subform that changes when i click buttons on the main form. Almost like the tab control but without using that control its not really what i am looking for. Is this possible?
Thanks for your help guys
Rich
ScottGem
Oct 24 2007, 08:54 AM
its possible but I wopuln't recommend it. You can make sure a form always occupies the same position by using the Left and Right properties.
fkegley
Oct 24 2007, 08:56 AM
Yes this is possible. Put a set of navigate buttons on the form you want to remain open. Place an UNBOUND subform control on the form you wish to remain open. In the click event of each navigate button set the subform controls' Source Object property to the appropriate form.
Sligo
Oct 24 2007, 08:59 AM
Yes, this is possible. I've done it a few times.
In code, you just change the "SourceObject" property of the child-form control on your parent form to the name of the new subform.
A couple cautions- don't use any field linking between the two forms. This is a parent form property and it would require that all the subforms have a recordsource that has the field in common on all of these. This isn't a practical approach.
When designing this, be very mindful of the size you have allocated for your subform. If you've set the size to 5" x 4" (for example) and your subform isn't that exact size, it looks pretty sloppy.
The best example where I have actually used this trick is on a form that launches reports. On the left, I have a list-box containing all my reports. When I choose a report, the area on the right is replaced with a subform containing the available criteria specific to that report. My "Print" button knows which subform I'm looking at so it knows what controls are there that need to be passed through to the chosen report. This leads to the final caution - you can reference controls on the subform from the parent form (and vice versa), but be very careful - the compiler doesn't trace through these levels. This is both good and bad. If you reference a control on your subform and it doesn't exist, you'll get a runtime error with a vague error message.
I hope this helps.
- Sligo
rjpatrick
Oct 24 2007, 10:32 AM
Hi thanks for the advice!
i know very little about code writing. do you know what code would i write for this?
Thanks again for your help
Sligo
Oct 24 2007, 10:55 AM
Rich,
Since I don't know your skill level, I don't know where to start. Let's just write a quick example from the top:
My parent form is "frmMainMenu". On it I have an unbound child-form control, called "Child1"
I have three child forms that I want to swap out:
"fsubCustomer", "fsubVendor", and "fsubInventory". (These are straightforward examples in a common retail or service based application, and these forms are such that you would select a record to edit and/or add a new record)
I have three buttons on my main menu:
cmdCustomer, cmdVendor, and cmdInventory.
When I click these buttons, I want to switch my "view" area to the appropriate subform. Here's what the code would look like for the cmdCustomer click event:
private sub cmdCustomer_Click()
me.child1.sourceobject = "fsubCustomer"
End sub
That's the easy part. Now, I'm going to sit back and wait for you to implement this and get it working. It's possible that this is all you need. However, I can imagine a myriad of possibilities where you may want to set up some kind of interface between the master (parent) form and the child subforms, but we'll cross that bridge when and if we get there.
I hope this helps.
- Sligo
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.