Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

code doesn't work for my real project and work in other

0

Hi Guys,

this  work  for  John_Ru .

in  reality  the  first  file  works  without  any problem , but  when try to  run  for  second file   it  will shows  error object doesn't support  this  property or method in this line 

ShowNextInv (Me.ActiveControl.Caption)
when select any optionbutton 

what's  the  mistake  guys?

Answer
Discuss

Answers

0
Selected Answer

Leap

The difference is that my UserForm was a simple form but (for some reason) you are using a miltipage (tabbed) design, currently with just one page. While Me remains as  UserForm1, it sees MultiPage1 as the active contraol (rather than the option buttons selected within that object)..

The simplest way to to fix it is to change the code to: 

Private Sub OptionButton1_Click()
 'Pass button caption to sub
 ShowNextInv (Me.OptionButton1.Caption)
End Sub

and likewise for buttons 2 and 3.

Discuss

Discussion

Hi John,

I thought  the  code  could  deal with  multipage  as in  form  without  make difference between each other .
thanks  very  much  for  correction & clarification.
leap (rep: 46) May 11, '23 at 8:57 am
Thanks for selecting my Answer, Leap. I guess you will be adding more pages to that form later.
John_Ru (rep: 6142) May 11, '23 at 9:16 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login