Label Caption Just Wont Work on UserForm
Thank you again for your suggestion.
I get a " Userform already open. Cannot show Userform modally " error message
I have tried placing Userform.Show / DeEvents at various places,
but I am stumped.
All I am trying to do is validate two dates in two different userform text boxes
, and get the User to resubmit them if they're invalid
Appreciate any other ideas from the Newsgroup.Thanks
Tom Ogilvy wrote:
There is nothing to stop the code from executing.
I think you want a Userform1.show somewhere in there (after you initialize
it)
Call ValidateDate( )
.....test for valid date here----
If TestDate = False Then
LabelMessage.Caption = "Invalid " & WhichDate & _
" Enter new date & Click Date Label"
Load UserForm1
With Userform1
If WhichDate = "StopDate" Then
.txtStopDate.Value = ""
.txtStopDate.SetFocus
.txtStopDate.SelStart = 0
.txtStopDate.SelLength = Len(txtStopDate.Text)
ElseIf WhichDate = "StartDate" Then
.txtStartDate.Value = ""
.txtStartDate.SetFocus
.txtStartDate.SelStart = 0
.txtStartDate.SelLength = Len(txtStartDate.Text)
End If
.show
End With
End If
end sub
perhaps. Don't know where txtStartDate and txtStopDate are located. Assume
Userform1.
K wrote in message
...
Thank you very much. This worked fine with just DoEvents.
I don't understand why the program does not yield to the User, as a
similar
problem occured when I tried to test two dates as follows
Private Sub cmbTestDates_Click()
Call lblStartDate_Click
Call lblStopDate_Click
End Sub
The program goes on to the second Call procedure before the User
interactions
required in the first one is completed. If I just have any one Call
procedure
it works fine.
The portion of the coding that requires User interaction looks like this.
Call ValidateDate( )
.....test for valid date here----
If TestDate = False Then
LabelMessage.Caption = "Invalid " & WhichDate & " Enter new date &
Click
Date Label"
Load UserForm1
If WhichDate = "StopDate" Then
txtStopDate.Value = ""
txtStopDate.SetFocus
txtStopDate.SelStart = 0
txtStopDate.SelLength = Len(txtStopDate.Text)
ElseIf WhichDate = "StartDate" Then
txtStartDate.Value = ""
txtStartDate.SetFocus
txtStartDate.SelStart = 0
txtStartDate.SelLength = Len(txtStartDate.Text)
End If
End If
end sub
Tom Ogilvy wrote:
Private Sub lblStartDate_Click()
Dim TCTestDate As String
TCTestDate = txtStartDate.Value
LabelMessage.Caption = "Testing Date. Please Wait"
' me.Repaint ' uncomment if DoEvents doesn't solve it
DoEvents
Call ValidateDate( )
End Sub
--
Regards,
Tom Ogilvy
K wrote in message
...
Hello
I just can't figure this out.
I am using Label Caption to deliver messages on a Userform (see below)
When I step through the procedure the Caption works. When I run it
does
not.
The ValidateDate Sub uses LabelMessage.Caption (different message) ,
and
this works fine when I run it.
When I move
LabelMessage.Caption = "Testing Date. Please Wait"
to within the VaildateDate Sub the same problem described above occurs
What am I missing
Thanks for any suggestions
Private Sub lblStartDate_Click()
Dim TCTestDate As String
TCTestDate = txtStartDate.Value
LabelMessage.Caption = "Testing Date. Please Wait"
Call ValidateDate( )
End Sub
|