Refer to Control within a Tab Control in VBA #2 (1 Viewer)

widemonk

Registered User.
Local time
Today, 04:12
Joined
Jun 16, 2005
Messages
48
I would like to add a reply to thread 27700 but when I go to it, I am logged out :confused:

I have a Tab Control on my form and have recently copy-pasted my controls on to it - however my VBA no longer works. From what I've read, each control (regardless of which tab its on) needs a unique name - check, and therefore can be referred to as if it were directly on the form and there was no Tab control.

txtDOB is the text field to store - you guessed it, a Date Of Birth.
lblAGE is a label to show "30 years, 3 months" etc, which is done by VBA within OnCurrent so it refreshes automatically as you move from person to person.

Now a simple bit of code like... lblAge.Caption = "test" creates runtime error 424; Object required.

It works directly on the form outside the realms of the Tab, but not on a Tab.

Form is called frmMembers
Tab Control called TabCtl1
Page Name called Page1

Any ideas please ???
 

stopher

AWF VIP
Local time
Today, 04:12
Joined
Feb 1, 2006
Messages
2,395
I could not replicate your problem or see any error in your logic. Can you post your database.

Chris
 

widemonk

Registered User.
Local time
Today, 04:12
Joined
Jun 16, 2005
Messages
48
Thanks for your input Stopher - all sorted.

Solution in case anyone else has the same problem...

When I copy and pasted the controls, of course it left the original ones in place (remember I used copy and paste, not CUT and paste). Once pasted correctly on the Tab, it gave them a whole new set of default names so when I deleted the original controls, the control name in VB didnt actually exist.

When pasting to a Tab control, you may need to check/rename your controls if VB or conditional formatting etc relies on them.:rolleyes:
 

Users who are viewing this thread

Top Bottom