Correct VBA syntax for a form field inside a tab control

JamesWB

Registered User.
Local time
Today, 17:56
Joined
Jul 14, 2014
Messages
70
Hi everyone. My first ever posting. :)

I have created a tab control called Localinfo in a form. There is only one page in the tab control called Localinfopage. I copied a textbox field called Town into the tab page.

From a combo box in the main parent form, I am attempting to enable a field in the tab control page when a value "UK" is selected. This works fine when the field is outside the tab control page. Inside it, I can't seem to find (and have searched hard with no success) the correct syntax.

This is what I have so far, needless to say, this doesn't work.

Private Sub AuCountry_AfterUpdate()
If Me.AuCountry.Value = "UK" Then
Me.Localinfopage.Town.Enabled = True
End If
End Sub

Private Sub Form_Load()
Me.Localinfopage.Town.Enabled = False
End Sub

How do I reach the properties of this Town field in the page control please?

Many thanks for any help! :)

James
 
Ignore the tab control; it is not part of the reference.

Me.Town.Enabled = False
 
Gosh you guys are good! :) That worked. My confusion had arisen from the way Access renames fields on the fly when you copy and paste them into a tab control, sigh.

I now have a separate problem.

Basically I have a combo box called AuCountry which has two possible options, "UK" and "NZ". If the user selects "UK", I want the Town field in the tab control page to be enabled again and this now happens.

Unfortunately, if the user then selects "NZ", it remains enabled.

Do I need to add an "Else If AuCountry = "NZ" Then Enabled=False" bit in the Sub as well? This seems like overkill?
 
Yes, you need the Else clause, but no test required, just set the property.
 
Yes, you need the Else clause, but no test required, just set the property.

Brilliant, all correct now.

Thanks so much for your help, I heard this was a good forum. :D
 
Happy to help, and welcome to the site by the way!
 

Users who are viewing this thread

Back
Top Bottom