Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Layered User Forms

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
Howdy all,

Does anyone know of a way to have multiple user forms loaded simultaneously and alternate control between them? I have a file where one form is loaded from another form, however the first form needs to stay visible and possibly active. Is there a way to alternate the order of the forms based on which form the user either hovers the mouse over or clicks?

Thanks in advance,
BD
 

BD,

Loading multiple forms is as simple as having each one load in order, but have the Visible characteristic for each one set to "False". As to keeping two forms visible at the same time, with the first (calling) form remaining active, there is a way. While it should be possible to use a MouseHover command, it can absolutely be done via a button on the second form. Clicking on it takes your to the original form, where you can have a button that would take you back to form 2 (etc.).

I've used the button call several times, but have never done anythning with hovering the mouse. I guarantee that the folks I code for would screw that up in a heartbeat, so I've never messed with it.

Let me know if you need to see some sample code and I'll post some in the morning. All of those files are at my day-job location.

{glasses]


----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was repossessed." [lol]
 
Thanks walker. I also have used the button method to swap between two loaded forms, I was hoping for another way. Basically the first form have a lot of various categories which when selected display the appropriate subcategory. The main users of the form requested the option of being able to click a link to a "cheat-sheet" table which would load in another form.

The user wanted the two forms to work basically as two IE windows would work, where you can select one drag and locate and vice versa. I have made it so the forms can be moved, resized, etc... I'm now looking for a way to simply interchange between the forms as you would two IE windows.

I think a mouseHover method could work, but there is a lot of potential for the user to get confused. I kind of hope to not have to add a commandbutton to swap, but if that is the only good solution well guess that will work. The problem is there isn't really a spot on the first form for an additional, somewhat pointless, commandbutton.
 

BD,

As noted, I've not used this before and thus hadn't researched it very well. This morning some time was devoted to reading all the Help File material to try and find an answer.

It looks as if you can do what you want via the MouseMove event. Your users would have to click on the new form to change the focus, but there shouldn't be too much objection to that since it is a fairly standard requirement in many applications. If this won't work I'm afraid you're going to be stuck with the button solution.

As far as the potential to get confused is concerned, you have put your finger on the reason I've never done the mouse bit. The folks I work with are by and large very good people, and I like most of them a lot, but they are not what you'd call computer literate. The Eye-Dee-Ten-Tee** problem is alive and well here!

[glasses]

** ID10T


----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was repossessed." [lol]
 
BD,

how about a multi-page with three pages approx. the size of the userform?
There are options to put the tabs on all four sides of the element and to make them appear like command buttons.

If the user wants to close the form after filling in any of the pages you might want to put only Esc- and OK-button underneath a fairly large multi-page (like in the assistants in Word 2k).
Otherwise you might want to make the multi-page the same size as the user-form and put OK and Esc on page three.

HTH.
 

BD's first post talks about more than one form being visible. Wouldn't a multi-page set-up defeat the concept of having multiple forms visible on screen at the same time? I'm probably missing something obvious here, but I'm not seeing how this would work given BD's constraints.

If it turns out this is one of those that is going to make me pound me forehead on my desk, break it to me gently - my boss is already threatening to make me pay for a new desk!

[glasses]


----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was repossessed." [lol]
 
Walker:
I would never doubt your competence, I was just trying to help.
But: if multiple forms are visible on the screen, the user is shown information on one of these (possibly inactive) multiple forms which may be necessary to fill in the (active) form.
Why shouldn't the same task be accomplished by repeating the relevant information on this one of the forms on the "active" form (maybe using multi-pages instead of forms)? It would save lot of complicated programming.
That is why I suggested a multi-page. Of course my post was insufficient.
And again - I never doubt(ed) your competence.

Markus
 

Markus,

It's nice to know that you didn't doubt my competence, because I do that all the time! This is especially true when something that is completely obvious to everyone else leaves me with that "WTFO?" blank stare on my face.

I'm now on the same page as you and Gerry (pun notwithstanding) and see what you mean. It took a while, but the concept has finally filtered through into what passes for a brain. You're right; doing it this way would be easier overall.

And please, don't feel that I was attacking your competence either. Everyone who posts here is trying to help; that is a given. I just simply, really, really didn't get it. As noted previously, this happens more often than I like. My wife says it's a sign of old age creeping up on me, but when I miss simple stuff such as this I think she's wrong - it isn't creeping up at all, it's pouncing and bludgeoning!

[glasses]


----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was repossessed." [lol]
 
Thanks for the posts guys!

I see the logig in using MultiPages, however it would not work in my situation. The second form to load is basically a help form for the users who are confused with the first form. Thus it would be helpful to be able to see the first form while reading the help form.

I ended up just changing both form's ShowModal property to false. This isn't the best method, but it should work until I find another way to accomplish the goal.
 
BD,

glad you've found a way.

In the same situation I would have put a small command button with caption "?" and a label for the help text on the form:
When user clicks command button, form would be enlarged, label would be filled with the help text and shown and caption of command button would change to "OK".
When user clicks command button again, label would disappear, form would return to its original size, command button caption would change to "?".

HTH.
 
I will not suggest using .chm files for Help, as frankly, they are difficult and a pain to set up. However, if the purpose is to give textual help, AND the text is relatively small, there is another possibility.

For example:

A label with text above a textbox.

(label) Client Preference - Click here for Help
(textbox)

Code:
Sub label_Click()
   Msgbox "Use yadda yadda to blah blah blah."
End Sub

As all input controls (textboxes, checkboxes etc.) should have a label - a general rule for useability - you can add small text "Help" to clicking the label.

It is not a be-all, end-all, solution, but it is a viable low level solution.

Depending on the structure/design, you can also have a generic Label that fills with appropriate text. Something like:
Code:
Private Sub TextBox1_Enter()
   Call FillLabel
End Sub

Private Sub TextBox2_Enter()
   Call FillLabel
End Sub

Private Sub TextBox3_Enter()
   Call FillLabel
End Sub

Private Sub TextBox4_Enter()
   Call FillLabel
End Sub


Sub FillLabel()
   Select Case ActiveControl.Name
      Case "TextBox1"
            lblHelp.Caption = _
               "text for textbox1 help...."
      Case "TextBox2"
            lblHelp.Caption = _
               "text for textbox2 help...."
      Case "TextBox3"
            lblHelp.Caption = _
               "text for textbox3 help...."
      Case "TextBox4"
            lblHelp.Caption = _
               "text for textbox4 help...."
 End Select
End Sub
A label (lblHelp) beside the texboxes (in this example there are four). As the user enters each textbox, the Label text is changed to display help text for THAT textbox.

Again, not a be-all solution by any means, but it can be useful in some circumstances. If the Help text is relatively small - we are not talking about pages and pages of hyperlinked content! - then having the content as text ( strings) within the userform module is quite reasonable.

You could also do the help content as constants, and dump those into the Help label as appropriate, like this:
Code:
Const T1_Help As String = "Yadda yadda, some text for" _
    & " Help on Textbox1"
   
Const T2_Help As String = "Blah blah ho hum, do you" _
    & " really need to know this about textbox2?"
   
Const T3_Help As String = "I am SO tired of you " & _
   "asking about Textbox3.  Have you not figured " & _
   "this out yet?"
   
Const T4_Help As String = " Ho hum...textbox4..." _
   & "AGAIN?????"

Private Sub TextBox1_Enter()
   lblHelp.Caption = T1_Help
End Sub

Private Sub TextBox2_Enter()
   lblHelp.Caption = T2_Help
End Sub

Private Sub TextBox3_Enter()
   lblHelp.Caption = T3_Help
End Sub

Private Sub TextBox4_Enter()
   lblHelp.Caption = T4_Help
End Sub
Again, the "Help" label content changes to where the user has focus.

faq219-2884

Gerry
My paintings and sculpture
 
I just want to add that Markus4 also has a good viable option, expanding the userform to show a Help area. Although I see no need for a commandbutton. A simple label with "?" will do the trick. It has a _Click event.

Click the "?" and the userform resizes to show the Help (in another Label).

The only issue I have with this approach is that it requires TWO clicks by the user. First to resize/show the Help area, and second to resize it back.

It ia valid, but I prefer the user to not have to click anything. If possible. But hey...sometime you just gotta do what ya gotta do.

faq219-2884

Gerry
My paintings and sculpture
 
Gerry, thank you. Of course you are completely right. The reason for my suggestion was:

Not in my life but in certain things I'm quite conservative. So, command buttons are just to be clicked on, list boxes are just to be scrolled and selected etc.
Thus I personally prefer to have a tiny button in the upper right corner of my form / frame instead of inviting the user to click on everything.

Markus
 
May be you can avoid any clicking by keeping the 'Help' Label visible and using something like;

Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Label1.Caption = "This is the button that does diddly de"
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Label1.Caption = "Help for controls on this Form will appear as you move the mouse over them"
End Sub

Private Sub UserForm_Activate()
Label1.Caption = "Help for controls on this Form will appear as you move the mouse over them"
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Label1.Caption = "This is the Form that does blah"
End Sub
 
Again, a viable option. There are many possibilities.

We have not heard from the OP regarding these alternatives. I guess my essential point is that IF the point of the second userform is strictly to hold help information, AND there are issues with modality - and/or switching between userforms - then one solution is to NOT have two userforms. Which is quite possible with the options we have mentioned.

This is in fact the main reason I avoid multiple userforms. True, there are circumstances when multiple userforms are the only route. However, I think these are truly few. VBA handles userforms well, and structuring them is a matter of design and the use of design logic.

I have made userforms that had 30 controls on them, but only six or seven visible at any given time. Depending on what the user is doing, or has input, the actual userform look (and its visble controls) changes. I resize the userform, make different controls visible. It looks like three or four different userforms operating, but it is really just ONE. It changes dynamically.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top