referencing tab on subform

M

MarkV

How do I reference a tab control on a subform?

I have a tab control on a subform. The tab has two
pages. I want to have the "on exit" event check if any of
the controls on page two only are null, and if so to not
exit subform.

So far I am having trouble referencing the tab page. What
I have is:
----------------------------
Dim ctl As Control
Dim tbc As TabControl
Dim pge As Page

' Tabctl32 is name of tab control
' [Add New Goals] is name of page 2

Set tbc = Me!TabCtl32![Add New Goals]

' The above line is a problem, error 451 Property let
' procedure not defined and property get procedure did not
' return an object

For Each ctl In tbc
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
If IsNull(ctl.Value) Then
MsgBox "Control is null", vbOKOnly
Else
MsgBox "control is not null", vbOKOnly
End If
End If
Next ctl

End Sub
 
M

Mal

just need to be a little more specific..
if you replace the me. with forms (in your head, not literally)
you'll see that the code is expecting to find the tabCtl32 on the main
form....which of course it isn't, its on the subform...
so...
just be a little more specific
me.subFrmName.TabCntrlName.TabPageName(if needed).ControlName
should get you there...

HTH
Mal.


Set tbc = Me!TabCtl32![Add New Goals]
 
T

TC

If sf is the name of the subform >control< on the main form:

- sf.form refers to the form within the subform control;
- sf.form![TabCtl32] refers to the tab control on that form;
- sf.form![TabCtl32].Pages is the Pages collection of that tab control.

So: (untested)

for each ctl in sf.form![TabCtl32].Pages(1).controls ' 1=page #2.
...
next

Or, to access the page by name instead of by number:

n =sf.form![TabCtl32].Pages![Add New Goals].pageindex
for each ctl in sf.form![TabCtl32].Pages(n)
...
next

Check "PageIndex" above, I'm not sure if that is the right property name (&
don't have Access here to check).

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top