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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with putting controls on tabcontrol page

Status
Not open for further replies.

hcg

Technical User
May 17, 2000
5
NL
I struggled with putting event-code (after_update event) for an optionbutton on a subform which was on a tabcontrol page. The reference to the event-code on the propertieslist of the particular optionbutton kept disappearing, but the code itself appeared to be still in the subform's module. I decided to get rid of the subform and put optionbuttons directly on the tabcontrol page on my mainform instead. Is there any way to do this through VB?
 
I'm not sure if I understand the question correctly, so if this isn't even close just disregard.

Since I'm not sure what you mean by "kept disappearing" I'll try to address the issue of using controls on a subform of a tab.

A tab can be considered a page of the form it is on. Controls on tab are considered part of the form itself. So for example, to address a particular control in VBA for the form you can use Me.ControlName. To address the control from another form or in areas that don't allow use of the Me. predicate you use Forms!FormName!Controlname. A control on a subform must use the full address of the control for everything except code behind the subform itself. Anything outside the subform that needs to be addressed from the subform must use the full path. For example, if I wanted to change the value of an unbound text box on the main form after changing a value in a control on a subform the code would look something like this:
Forms!MainFormName!UnboundControlname = Me.ControlThatChanged

where 'ControlThatChanged' and the code making the call are both on the subform.

Likewise you could do the opposite, change a value on a subform after changing one on the mainform:

Forms!MainFormName!SubFormName!ControlToChange = Me.ControlThatChanged.
 
I think I know what you mean by the "disappearing." One of the annoyances of Access is that if you cut & paste a control the "On____" property listing is lost. Whenever you move them from one form section to another check the reference for the event.

General item: Controls can be cut & pasted from one page to another or copied (also from outside of the tab page control). The foolproof way to do it is (1) make sure the page itself is selected and (2) use Edit > Paste Special and Accept the Item # X offered in the box. Otherwise the controls will ghost through all of the pages (although this can be useful to create a reference to ID visible in all pages).
 
I am using VB to create new forms and actually put controls like textboxes and optionbuttons on those forms; this code acts a bit like a formwizard in some way. I am using the CreateControl method for this. According to the MS-Access help file this can only be used on forms: CreateControl(formname, controltype[, section[, parent[, columnname[, left[, top[, width[, height]]]]]]]). However I would like to put controls on a tab using VB.
 
Quick Thought: Have you tried creating the control on the form, then setting its parent property to the tab? And if that works, remember that you would still need to deal with setting the new control's physical position on the form and/or tab. (untested idea, just another angle to try.)

(Working with the Tab Control myself right now, wondering why seting the Top property changes the control's height *instead of* its vertical placement on the form :{ ...)

-- C Vigil =)
(Before becoming a member, I also signed on several posts as
"JustPassingThru" and "QuickieBoy" -- as in "Giving Quick Answers")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top