Tab Control

  • Thread starter Thread starter lmcgowan
  • Start date Start date
L

lmcgowan

Guest
I want to insert a tab contorl onto a form. These controls already exist on the form and the way that you are told to pot then on the tab control is to either copy them from the form or drag them from the field list. This means that you loose the code behind the controls and have to rename them. I have some code on the form which reads.

Forms!frmProblem.lblpip.Visible = False

this piece of code works on the form but as soon as i copy it into the tab (tab) on the page (pip) and change the code to

Forms!frmProblem.tab.pip.blpip.Visible = False

It no longer works. I really want the same functionality as before but an having real difficulty copying these controld over to a tab control.

Please help..
 
Try this I believe it will help...

Me.TabCltName.Pages(PageNumber).FieldName.Visible = False

The PageNumber is the number Order on your tab forms, for example the first Page = 0, the second = 1, etc...

So You Code Would look something like this if the PIP page was the second tab:

Me.Tab.Pages(1).blpip.visible = False

Hope I am understanding you correctly.
 
Tab Control nightmare
Hiya

I am still having some problems. I am trying this code on a spare form and I keep on getting runtime errors. Below is the code which I am having these errors with. I have a check box which has the following event procedure on the onclick event. The (test) field is a label which is hidden and what I want is that if the tick box is ticked then the label is shown and if it is unticked then it is hidded. The tabcontrol is called tab and the code is on the first page of this control. Please help. I am probably doing something really silly.

Private Sub Check7_Click()
If Me.tab.Pages(0).Check7.Value = True Then
Me.tab.Pages(0).test.Visible = False
Else
Me.tab.Pages(0).test.Visible = True
End If
End Sub
 
Also in my database I have controls on the form which i want to move onto a tab control on the same form, but apparently the only way i can do this is to copy them over or insert them on the form using the field list. When this happens I have to rename the controls and I loose the code which is behind them meaning that I have to do that again. Is there anyway that this can be done so that I can simply move the code from the form onto the tab control. Thanks, hoping to hear from you soon.
 
The tab control and the pages aren't subforms so (I think) you should be able to refer to the label and the checkbox as though they are on the same form where you have the tab control.

e.g. me.label1.visible = false instead of Me.tab.page1.label1 etc.
 
tend to agree with naygl. You should be able to directly reference the control.
Also the method I have used to "check" a check box is

Private Sub Check7_Click()

If Me.Check7 = -1 Then 'true
Me!test.Visible = true
Else
Me!test.Visible = false
End If

End Sub

One value for the check box is 0 (False or unchecked), the other is -1 (True or checked)

Don't think you need the .value

Dave
 
PS
On thinking
When you cut a control from your form and paste it onto your tabbed page, if the name has changed, change it back to the original name and be sure to select [event procedure] under the on click event. The code you created doesn't get deleted from the code page, just sits there not being used.

Dave
 
Tab Controls

Thanks Guys

This worked a treat, its amazing the things that you can fit in a form using a tab control.

Thanks again

Lisa
 
Just for the record, you could simplify this by changing to:

Private Sub Check7_Click()
'If Check7 = true, test is visible. If false, not visible.

Me!test.Visible = (Me.Check7 = -1)

End Sub
 

Users who are viewing this thread

Back
Top Bottom