2 userforms modeless taking focus back to another in a certain object

excel 2010 vba

I have 2 userforms  both modeless.
Userform1
Userform2

I open useform1
Then userform2
 
and once I'm done with userform2
I want to move the focus back to userform1


Problem.  I have Multipage object on Userform1. ( 8 tabs  )

First I need to make sure when I move back to the Useform1 I go to the right place.

So
if on Useform1 ,  Multipage (2) was the current tab,   I want to go to listbox2
that has a currently selected Item ?




Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Martin LissConnect With a Mentor Older than dirtCommented:
Listbox1.Listindex will tell you which one is selected, if you just need to know the value you can do Listbox1.Text
0
 
Martin LissOlder than dirtCommented:
In userform2 Terminate event put code that selects userform1.multipage(2) or userform1.ListBox2.Setfocus
0
 
Martin LissOlder than dirtCommented:
You may have to do

userform1.show
userform1.ListBox2.Setfocus
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
FordraidersAuthor Commented:
ok..that sounds simple enough..

But,  would i not have to loop through the listbox and see which one has the item selected to back to that item ?

i.e. If i had 20 items in the listbox and 17 was selected..i need to go back to that line in the listbox...

Thanks
0
 
FordraidersAuthor Commented:
Thanks
0
 
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 - 2012
0
 
FordraidersAuthor Commented:
Martinliss,

these are the actual values Im using:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
frmResultAll.MultiPage1.SetFocus
frmResultAll.MultiPage1.Value = 0
frmResultAll.ListBox1.SetFocus
Unload UserForm1
end sub


The focus is still on the sheet1...

The userform
frmResultAll  does not get the focus..?
0
 
FordraidersAuthor Commented:
ok for some reason got this to work...sorry to bother you...

The form is already showing...but

I forgot your first line of code..!



frmResultAll.Show
frmResultAll.MultiPage1.SetFocus
frmResultAll.ListBox1.SetFocus
Unload UserForm1
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.