Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I use a user form in which the user shall enter a date in a text field. I
then have a sub that checks if the date is valid. If not so I show a message box. However I want the program to show the message box and when the user clicks OK I want the user form to still be shown. Private Sub checkDate() If (Not (IsDate(userForm1.TextBox1.Text))) Then MsgBox ("Date not valid") End If If (Not (IsDate(userForm1.TextBox2.Text))) Then MsgBox ("Date not valid") Else: Call mainProgram End If End Sub The problem is that I do not know how to write a sub that just shows the user form. Now I just have a sub that gives instructions when the user clicks a button on the user form. This sub calls checkDate as you can see below. Private Sub genereraRapportKnapp_Click() Call checkDate Call mainProgram Unload Me End Sub The user form is created in a Modul when pressing a button. Public Sub startKnapp_Click() userForm1.Show End Sub If anyone has a clue how to solve this please help me, I seem to be quite lost....Thank you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Once the user form is shown, it won't go away until it's unloaded. You
can make it modeless if you want the user to be able to work "around" it. userForm1.Show vbmodeless You already have the line to show the userform... userForm1.Show just put it in a sub. sub ShowForm1 () userForm1.Show end sub You can then call the sub from other procedures if you want. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thank you ver much for your reply! However, when I call the sub that contains
the code: userForm1.show I get the message that the form is already displayed. I just want to go back to the user form, preferably with the same info as the user already has entered into the different fields. Do you see my problem? Any help you can give me is very much appreciated! Yours sincerly, Franz Klammer "ward376" skrev: Once the user form is shown, it won't go away until it's unloaded. You can make it modeless if you want the user to be able to work "around" it. userForm1.Show vbmodeless You already have the line to show the userform... userForm1.Show just put it in a sub. sub ShowForm1 () userForm1.Show end sub You can then call the sub from other procedures if you want. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() If you show the form modeless and remove the "Unload Me" line from your calling sub, the userform will "float" on top and "hold" any parameters entered. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What I think you're doing....
1. You have a userform you created that has a button or two that checks textboxes where you want folks to entere dates. If they entere dates that are not valid, you pop up a message box to tell them. THE PROBLEM is that once they click thorugh the message box, the form is blanked out or unloaded or you just can't see it. What I think you want to do.... A. Warn them B. Don't dump the form Get rid of the code "call main program" All you need to do is run the code to check if it is a date or not then pop the msgbox. Nothing else. If you don't really care what info they put in there and just want to warn them, highlight the text box when the exit the box. Something like this: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If IsDate(TextBox1.Value) = False Then TextBox1.BackColor = &HFF& Else TextBox1.BackColor = &HFFFFFF End If End Sub if you really want to force them to enter the date appropriately, (assuming you have a final button or routine they click to save their entry....) just enter a snip of code in the routine that goes something like this... sub savebutton_click() Dim DateFlag As Boolean If IsDate(TextBox1.Value) = False Then DateFlag = True If IsDate(TextBox2.Value) = False Then DateFlag = True If IsDate(TextBox3.Value) = False Then DateFlag = True If DateFlag = True Then MsgBox "You need to enter the right date in the red boxes": Exit Sub End If end sub ===== Regards, Jamie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Userform to enter values and shown in same userform in list | Excel Programming | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
Activating userform and filling it with data form row where userform is activate | Excel Programming | |||
Access from add_in userform to main template userform.... | Excel Programming | |||
Linking userform to userform in Excel 2003 | Excel Programming |