Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

UserForm Question

  Asked By: Sam    Date: Aug 11    Category: MS Office    Views: 637
  

I have a userform with a mutipage form on it. There are several "edit" buttons
on each mutipage.

right now, this works

Private Sub BDFB_Edit1_Click()
'Edit information on the datasheet based on the object name
'Test if we are looking at 1-9, or 10 through 40
'We need to know if we want the last two digits of the name
'or just the last one to know what row number to edit.

NameLength = Len(Me.BDFB_Edit1.Name)
RowNumber = Right(Me.BDFB_Edit1.Name, NameLength - 9) ' "BDFB_Edit" is 9
characters
Call BDFBRowEdit(RowNumber)
End Sub

Since this is 1 of 40, I would like the macro to be smart enough to know it
is. I don't want to have to place it's name in the macro if it can figure out
who is already, thus saving me alot of editing on the other 39.

How do I extract the "Edit" button's name with code?

Private Sub BDFB_Edit1_Click()
'Edit information on the datasheet based on the object name
'Test if we are looking at 1-9, or 10 through 40
'We need to know if we want the last two digits of the name
'or just the last one to know what row number to edit.

'not working, looking for the enabled object
MyName = Me.ActiveControl.ControlSource.Name

NameLength = Len(MyName)
RowNumber = Right(MyName, NameLength - 9) ' "BDFB_Edit" is 9 characters
Call BDFBRowEdit(RowNumber)
End Sub

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Edward Jones     Answered On: Aug 11

Try sticking some msgBox s in the code to show you what expressions you are
coming up with, or put a break before the relevant line and look at the
variables with the mouseover (or put ?MyName in the immediate window.)

 
Didn't find what you were looking for? Find more on UserForm Question Or get search suggestion and latest updates.




Tagged: