Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Newbie question on UserForm

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Newbie question on UserForm

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





  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Newbie question on UserForm

There are many ways, which one to choose is a question of style and taste. Here's one
solution with Textbox1, Label1 and CommandButton1 (the "OK" button, "Next" button,
whatever). In this demo the user must enter a valid future date in the date format of her
own choice. Note that "datevalue" says "this year" if no year is entered, so Jan 1. is
interpreted as Jan 1. 2003.

Private Sub CommandButton1_Click()
Dim D As Date
If IsDate(TextBox1.Text) Then
D = DateValue(TextBox1.Text)
If D < Date Then
Label1.Caption = "That's the past!"
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
TextBox1.SetFocus
Else
'date is fine, whatever ordinary button actions here
Unload Me 'close form, if desired
End If
Else
Label1.Caption = "Please enter a proper date."
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
TextBox1.SetFocus
End If
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"K" wrote in message ...
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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Newbie question on UserForm

Thank you

Unfortunately I am still having problems. I used the Do Until command to pause the program
while the User inputs the new date. However, the UserForm disappears (or partially visible and
stuck) so its not possible to make the change. I tried UserForm1.Show as shown in the coding
below, but this yields an error (the Userform is already showing). Appreciate any suggestions.

If DateFound = 0 Then 'The date provided is not valid
LabelMessage.Caption = "Database does not contain specified Stop Date. Please enter new
Stop Date"

txtStopDate.Value = ""
txtStopDate.SelStart = 0
txtStopDate.SelLength = Len(txtStopDate.Text)
txtStopDate.SetFocus

Do Until Len(txtStopDate) = 8
UserForm1.Show
Loop
GoTo StopDate 'This validates the newly provided

End If


Harald Staff wrote:

There are many ways, which one to choose is a question of style and taste. Here's one
solution with Textbox1, Label1 and CommandButton1 (the "OK" button, "Next" button,
whatever). In this demo the user must enter a valid future date in the date format of her
own choice. Note that "datevalue" says "this year" if no year is entered, so Jan 1. is
interpreted as Jan 1. 2003.

Private Sub CommandButton1_Click()
Dim D As Date
If IsDate(TextBox1.Text) Then
D = DateValue(TextBox1.Text)
If D < Date Then
Label1.Caption = "That's the past!"
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
TextBox1.SetFocus
Else
'date is fine, whatever ordinary button actions here
Unload Me 'close form, if desired
End If
Else
Label1.Caption = "Please enter a proper date."
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
TextBox1.SetFocus
End If
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"K" wrote in message ...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question wayne New Users to Excel 6 June 27th 08 02:23 PM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
newbie userform problem Kevin Excel Programming 1 August 5th 03 12:25 AM
Newbie Question Random Excel Programming 2 August 3rd 03 03:25 PM


All times are GMT +1. The time now is 05:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"