Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you for the response. I (newbie) am confused about the flow. Is it
cmbGo_Click ( ) txtStopDate.SetFocus txtStopDate.Start = 0 txtStopDate.SelLength =8 Call ValidateDate End ValidateDate ( ) 'Test for validity of date If DateFound = 0 Then Inform user and Exit .... End The User enters a date and clicks the Go button. The Click checks the length of the text entry (=8) and calls the procedure to validate the date? The ValidateDate procedure finds an error (informs the user) and exits? Thanks Ronald Dodge wrote: The side affect that you are seeing is probably a result of the code constantly running with the Do...Until code, thus not refreshing the screen as you would like it to. To avoid this sort of issue, 2 things to consider: Setup a command button and use as the default button for when the date is entered (if not already done), and If the data validation did not pass on the date entry, use the SetFocus within the command button's click event on the Date's textbox object, then set the SelStart and SelLength properties on the textbox. -- Ronald R. Dodge, Jr. Production Statistician Master MOUS 2000 "K" wrote in message ... In this situation the User inputs an invalid date in a Userform text box, the program then requests a valid date. 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 = "" 'Clear the text box containing the wrong date txtStopDate.SelStart = 0 txtStopDate.SelLength = Len(txtStopDate.Text) txtStopDate.SetFocus Do Until Len(txtStopDate) = 8 'Check that the text box contains a date UserForm1.Show 'This code creates an error Loop GoTo StopDate 'This validates the newly provided End If |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You close, but slightly off. I am assuming you have ValidateDate as a
function and it returns either a date or false. Private Sub cmbGo_Click() If ValidateDate Then 'Passed validation Perform Action based on the correct Date Else 'Failed validation txtStopDate.SetFocus txtStopDate.Start = 0 txtStopDate.SelLength = Len(txtStopDate.Text) End If End Sub -- Ronald R. Dodge, Jr. Production Statistician Master MOUS 2000 "K" wrote in message ... Thank you for the response. I (newbie) am confused about the flow. Is it cmbGo_Click ( ) txtStopDate.SetFocus txtStopDate.Start = 0 txtStopDate.SelLength =8 Call ValidateDate End ValidateDate ( ) 'Test for validity of date If DateFound = 0 Then Inform user and Exit ... End The User enters a date and clicks the Go button. The Click checks the length of the text entry (=8) and calls the procedure to validate the date? The ValidateDate procedure finds an error (informs the user) and exits? Thanks Ronald Dodge wrote: The side affect that you are seeing is probably a result of the code constantly running with the Do...Until code, thus not refreshing the screen as you would like it to. To avoid this sort of issue, 2 things to consider: Setup a command button and use as the default button for when the date is entered (if not already done), and If the data validation did not pass on the date entry, use the SetFocus within the command button's click event on the Date's textbox object, then set the SelStart and SelLength properties on the textbox. -- Ronald R. Dodge, Jr. Production Statistician Master MOUS 2000 "K" wrote in message ... In this situation the User inputs an invalid date in a Userform text box, the program then requests a valid date. 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 = "" 'Clear the text box containing the wrong date txtStopDate.SelStart = 0 txtStopDate.SelLength = Len(txtStopDate.Text) txtStopDate.SetFocus Do Until Len(txtStopDate) = 8 'Check that the text box contains a date UserForm1.Show 'This code creates an error Loop GoTo StopDate 'This validates the newly provided End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UserForm, with no input | Excel Discussion (Misc queries) | |||
Prompt user for input and utilize that input | Excel Worksheet Functions | |||
Have user input converted to uppercase in same cell as input? | New Users to Excel | |||
Formatiing a input Box in a Userform | Excel Discussion (Misc queries) | |||
Use userform to get input and compare to a hidden sheet | Excel Discussion (Misc queries) |