Having a couple problems and nothing I've seen has given me a solution...hopefully someone out there can help me.
The code below is just a portion of the overall program (which involves at least five userforms and a multitude of objects), but is directly where my issue resides.
An explanation of the portion:
Basically, the user keys in a number - depending on the particular user, it may be either a 5-digit numeric or a 7-digit (the 5-digit # with two leading zeroes). Input must be 5 digit (without leading zeroes), or 7 digit (with leading zeroes only).
An explanation of the problems:
I've used both inputbox and msgbox to alert the user to an incorrect entry. With the former, they can input the correct number. However, at that point the input is outside the select process and there's no input error-trapping. Given that the input will most usually be correct on the re-entry, I do not like carte blanche input and would prefer to continue double-checking input data. All I can see to do is build more if-then loops with each re-entry - hopefully there's a less convoluted way?
With the latter (msgbox), upon response, the cursor moves to the next textbox. Since I'm attempting to simplify user input, making them back up via keyboard or mouse to correct their entry isn't effective. I've used setfocus as well as a couple other solutions offered within the board, but nothing has worked.
Hopefully my explanations are clear...and the solution(s) exists.
Thanks to all -
lr
The code below is just a portion of the overall program (which involves at least five userforms and a multitude of objects), but is directly where my issue resides.
An explanation of the portion:
Basically, the user keys in a number - depending on the particular user, it may be either a 5-digit numeric or a 7-digit (the 5-digit # with two leading zeroes). Input must be 5 digit (without leading zeroes), or 7 digit (with leading zeroes only).
An explanation of the problems:
I've used both inputbox and msgbox to alert the user to an incorrect entry. With the former, they can input the correct number. However, at that point the input is outside the select process and there's no input error-trapping. Given that the input will most usually be correct on the re-entry, I do not like carte blanche input and would prefer to continue double-checking input data. All I can see to do is build more if-then loops with each re-entry - hopefully there's a less convoluted way?
With the latter (msgbox), upon response, the cursor moves to the next textbox. Since I'm attempting to simplify user input, making them back up via keyboard or mouse to correct their entry isn't effective. I've used setfocus as well as a couple other solutions offered within the board, but nothing has worked.
Hopefully my explanations are clear...and the solution(s) exists.
Thanks to all -
lr
Code:
Private Sub TextBox6_afterupdate()
Dim ordr, ordlen, ordopn As String
Dim Msg, Style, Title, Help, Ctxt, default, Response
Dim compapp
ordr = Trim(userform1.TextBox6.Text)
ordlen = Len(ordr)
ordopn = Left(ordr, 2)
Select Case ordlen
Case 5
If ordopn <> "00" Then
ordr = "00" & ordr
TextBox6.Text = ordr
Else
Message = "Incorrect Order Number" ' Set prompt.
Title = "Input Error" ' Set title.
default = ordr ' Set default.
Response = InputBox(Message, Title, default)
ordr = Response
TextBox6.Text = ordr
End If
Case 7
If ordopn <> "00" Then
Message = "Incorrect Order Number" ' Set prompt.
Title = "Input Error" ' Set title.
default = ordr ' Set default.
Response = InputBox(Message, Title, default)
ordr = Response
TextBox6.Text = ordr
End If
Case Else
Message = "Incorrect Order Number" ' Set prompt.
Title = "Input Error" ' Set title.
default = ordr ' Set default.
Response = InputBox(Message, Title, default)
ordr = Response
TextBox6.Text = ordr
End Select