View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
K[_3_] K[_3_] is offline
external usenet poster
 
Posts: 9
Default Newbie question on UserForm

Hello

Thanks. My problem seems to be that when the MsgBox message is displayed the UserForm is
disabled although the it's visible.

Is there another to way to tell the User that the date is invalid and to submit another one.

Thanks

Harald Staff wrote:

Hi

Don't put show in the initialize event, call it whan you need it from the main code. Try
hide-show like this:

Sub test()
MsgBox "Starting modeless"
UserForm1.Show vbModeless
If MsgBox("Modal ?", vbYesNo + vbQuestion) = vbYes Then
UserForm1.Hide
UserForm1.Show
End If
End Sub

A modeless form does no good combined with messageboxes, since those are /very/ modal. You
should imo use labels and buttons on the userform for information and interaction, not
those annoying msgboxes. But you may of course have your reasons.

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"K" wrote in message ...
I am trying to do the following.

The user enters a date (StopDate) in a UserForm text box.
The program checks the date , then asks the User if she wants to change
the date
The User says Yes, then changes the date in the text box, and the
program continues with the new value.

I have the following

UserForm_Initialize( )

UserForm.Show vbModeless

and in the main program I have:

res = MsgBox("Stop Date: " & Dates(iLastDay) & " Yes to Continue, No to
Change Date", vbYesNo + vbCritical)

If res = vbNo Then
UserForm1.Show 'Expecting the UserForm to become active to allow the
User to make the changes
MsgBox "Stop Date Changed ?"
TCStopDate = txtStopDate.Value 'The program picks up the new date
and continues

However this does not work.. The UserForm does not activate to allow the
user to make changes.

Appreciate any suggestions thank you