Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab, Subform & Footer confusion

Status
Not open for further replies.

theog

Programmer
May 1, 2001
13
US
TIA for any help...

I have a main form, on which I have a tab control, and each tab has a subform.

On the main form, I have command buttons in the footer ('Add New Record', 'Save Current Record', 'Delete Current Record') to do the appropriate things in each tab/subform, but the code behind the buttons, for example the 'Delete Current Record' button:
~~~~~~~~~~~
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
~~~~~~~~~~~
doesn't work. I suspect I'm not referencing things in my tab control and/or subforms correctly, but no syntax I've tried will work and I'm hopelessly confused (which is not abnormal) and frustrated.

Hope I've explained that coherently enough. Any advice?
 
Let’s begin with the rule everyone forgets at least one time. Command buttons are relevant to the form on which they appear; not to a subform, the subform of a subform, etc ad nauseum.

Your command buttons are on the footer of your main form. Using the code you are using, you are acting on the main form not the sub form.

The easiest and in my opinion one of the best approaches to take is to keep your command buttons in the footer of every form in use….main form buttons for main form; sub form buttons for sub form. That way, when you are updating a subform and you click the save button, you will be updating the sub form.

Also, keep in mind, when you leave a subform, ie, return to the main form, the default behavior is to update the subform on loosing the focus of the subform.

Yes, there are ways to have a series of command buttons on the main form govern what happens within your sub forms as well as on your main form but unless you are very comfortable referring to the child object(s) of your main form, you might want to get very comfortable with the more standard concepts.
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Robert,

Your explanation helped me with the fundamentals of form/subform usage and behavior. I truly appreciate your time and response.

I did find an elegant and simple way to control a subform's record via a button on the main form, so my desired (albeit more difficult) method of form layout (described above) is now working for me. For anyone interested, the link containing the explanation and code is:

Due credit (and my thanks) goes to Access MVP ACG Soft of Ann Arbor, Michigan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top