PDA

View Full Version : Userform management



makako
08-26-2006, 08:10 PM
Hi, Im having some problems with hiddin the userform when asking for info. For example I tried to set a userform with a button. when it is actioned, the userform must hide, ask for some variables through Inpubox commands and then re-appear. I used .hide, action the inputboxes and then .show but when the .show sentence is reached, the proceeding code is never reached until the userform is terminated. I have also tried with the visible property but I keep gettin some errors. Is there an easy way to "disappear" a userform without having so much trouble with the code? thanks

makako
08-26-2006, 08:17 PM
Example

Bob Phillips
08-27-2006, 04:47 AM
Example

Works fine for me.

makako
08-27-2006, 07:27 AM
It pops a message (in the visible button) that says the function or the interface is marked as restricted or the function uses an automatization non admitted in VBA, and in the show/hide it never reaches the code .backcolor until I terminate the userform. It is obvious I could move it before the show sentence but this is just an example of a much complicated addin Im working on and on various actions i have to hide and show the userform.
(I tried granting access to VBA proyects but the resut is the same)

Norie
08-27-2006, 07:37 AM
makako

Why are you using inputboxes and a userform?

Surely that defeats the purpose of the userform?

Bob Phillips
08-27-2006, 08:31 AM
I see how you are getting that now.

You have this code



UserForm1.Visible = False


You know that is not how you hide the form, you use



Userform1.Hide


which is the correct way.

makako
08-27-2006, 01:37 PM
I use the inputbox to add new data and the textboxes for modifying. Plus I also run some cheks with the inputboxes. In my example I set two buttons, one with visible and other with hide/show. I get the mentioned error with the .visible way but when using the hide and show way it nerver reaches (as I mentioned before) the following code

Bob Phillips
08-27-2006, 03:11 PM
This coide



Private Sub CommandButton2_Click()
UserForm1.Hide
Var = InputBox("Code")
Var = InputBox("Code")
UserForm1.Show
CommandButton1.BackColor = vbBlue
End Sub


works fine for me

makako
08-27-2006, 04:39 PM
Maybe Ive not been clear enough. Do you get your button turn blue?, cause when it reaches userform.show it never reaches the turn blue until I terminate the userform. Thats not the idea. Another example, If I want to send a msgbox without the userform to be on screen, can I hide it and then make it visible and hace the code continue without waiting to be terminated?

Norie
08-27-2006, 07:15 PM
I'll repeat what I said.
makako

Why are you using inputboxes and a userform?

Surely that defeats the purpose of the userform?

lucas
08-27-2006, 07:35 PM
Private Sub CommandButton2_Click()
UserForm1.Hide
Var = InputBox("Code")
Var = InputBox("Code")
CommandButton2.BackColor = vbBlue
UserForm1.Show
End Sub

makako
08-29-2006, 05:54 AM
Norie, its a dummy of a much more complex userform, Forget about the inputbox, try a message box when unacceptable data is entered and I dont want the userform to be seen when the msgbox is shown. If i use the show/hide instance the following code will never be reached after showing the userform. And Lucas,
... userform. It is obvious I could move it before the show sentence but this is just an example of a much complicated addin Im working on and on various actions i have to hide and show the userform. ...

Let me change the thread: Is there anyway I can use the visible property instead?

johnske
08-29-2006, 03:54 PM
...
Let me change the thread: Is there anyway I can use the visible property instead?No, click on the userform and look in the properties window. You'll see 'Visible' is not a userform property (that's why you were getting an error msg)

makako
08-30-2006, 04:56 PM
yes, but when it write userform1. the list allows me the visible property. thanks anyway.

johnske
08-30-2006, 05:10 PM
If you're referring to the intellisense list, the visible there is only intended to be used as a boolean test e.g. If UserForm1.Visible Then MsgBox "Userform1 is Visible"

makako
08-30-2006, 11:26 PM
ok, thanks

Jan Karel Pieterse
08-31-2006, 11:22 PM
You could of course just move the form out of sight:
Private Sub CommandButton1_Click()
Dim dTop As Double
dTop = Me.Top
Me.Top = 2000
MsgBox "Form is out of the way"
Me.Top = dTop
End Sub

makako
09-01-2006, 08:50 AM
thanks, more useful of all replies until now