Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a textbox called txtStartLotNumber on a form called frmLotNumber. That's all that's on the form, along with an OK and Cancel button. When user enters into textbox, and clicks OK, in need to verify the entry, before the rest of the code in the OK button executes. The entry has to be: - A six digit number OR -A five digit number, preceeded by an 'M', or an 'S', or a 'R' If those conditions are met, the sub continues, If not, a message indicating an 'Invalid Entry' displays, then cycles back (a loop?) to the frmLotNumber to reenter a valid lot number. As usual, Thanks for any help! -Steve |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The entry has to be:
- A six digit number OR -A five digit number, preceeded by an 'M', or an 'S', or a 'R' You can test the entry like this... If Entry Like "[0-9MSR]#####" Then ' VALID entry Else ' INVALID entry End If Note that the test is case sensitive; that is, it will validate on M, S or R as the first character and fail if m, s or r is used instead. If you need the test to be case insensitive, then change the If..Then statement to this... If Entry Like "[0-9MmSsRr]#####" Then Rick Rothstein (MVP - Excel) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 4 Dec 2011 08:26:39 -0800 (PST), SS wrote:
Hi, I have a textbox called txtStartLotNumber on a form called frmLotNumber. That's all that's on the form, along with an OK and Cancel button. When user enters into textbox, and clicks OK, in need to verify the entry, before the rest of the code in the OK button executes. The entry has to be: - A six digit number OR -A five digit number, preceeded by an 'M', or an 'S', or a 'R' If those conditions are met, the sub continues, If not, a message indicating an 'Invalid Entry' displays, then cycles back (a loop?) to the frmLotNumber to reenter a valid lot number. As usual, Thanks for any help! -Steve frmLotNumber Like "[RMS0-9]#####" will return TRUE or FALSE and you can incorporate this into your code to branch to whatever. So something like: Do Until frmLotNumber Like "[RMS0-9]#####" msgbox("Invalid Entry") 'Redisplay text box loop |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Dec 4, 12:58*pm, Ron Rosenfeld wrote:
On Sun, 4 Dec 2011 08:26:39 -0800 (PST), SS wrote: Hi, I have a textbox called txtStartLotNumber on a form called frmLotNumber. That's all that's on the form, along with an OK and Cancel button. When user enters into textbox, and clicks OK, in need to verify the entry, before the rest of the code in the OK button executes. The entry has to be: - A six digit number OR -A five digit number, preceeded by an 'M', or an 'S', or a 'R' If those conditions are met, the sub continues, If not, a message indicating an 'Invalid Entry' displays, then cycles back (a loop?) to the frmLotNumber to reenter a valid lot number. As usual, Thanks for any help! -Steve frmLotNumber Like "[RMS0-9]#####" will return TRUE or FALSE and you can incorporate this into your code to branch to whatever. So something like: Do Until frmLotNumber Like "[RMS0-9]#####" * * * * msgbox("Invalid Entry") * * * * 'Redisplay text box loop- Hide quoted text - - Show quoted text - Thanks Gentlemen!! I used this, and it works Beautifully!! Do Until frmLotNumber.txtStartLotNumber Like "[RrMmSs0-9]#####" MsgBox ("Invalid Entry") txtStartLotNumber.SetFocus Exit Sub Loop |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 4 Dec 2011 11:50:33 -0800 (PST), SS wrote:
On Dec 4, 12:58*pm, Ron Rosenfeld wrote: frmLotNumber Like "[RMS0-9]#####" will return TRUE or FALSE and you can incorporate this into your code to branch to whatever. So something like: Do Until frmLotNumber Like "[RMS0-9]#####" * * * * msgbox("Invalid Entry") * * * * 'Redisplay text box loop- Hide quoted text - - Show quoted text - Thanks Gentlemen!! I used this, and it works Beautifully!! Do Until frmLotNumber.txtStartLotNumber Like "[RrMmSs0-9]#####" MsgBox ("Invalid Entry") txtStartLotNumber.SetFocus Exit Sub Loop Glad to help. Thanks for the feedback. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Textbox Clear last entry | Excel Programming | |||
column of entry for textbox value | Excel Programming | |||
Validate textbox entry | Excel Programming | |||
Validate Textbox entry | Excel Programming | |||
Validating Entry into Textbox | Excel Programming |