K
kazzy
Hi Excel VBA advisers!
I have a userform where there are two text boxes (drugdesc1 &
drugdesc2) that I want to force 4 commas to be keyed into both fields.
4 commas are MANDATORY in each text box & are used to separate the
type of input within each. ie; brand name, ingredients, strength,
form, pack size. (FYI: Later on, I split these fields into 4 separate
columns based on the comma delimiter.)
When "cmdAdd" command button is clicked, I need to display a msgbox to
advise user and disallow the add.
I imagine that the code (repeated for each text box) that I would put
in the "sub cmdAdd" procedure would go something like this:
If Me.txtdrugdesc1.Value = ' this is the part I need help with.
Perhaps it's the =Len function?
Then
MsgBox "Please key in four commas into Drug Description 1!",
vbExclamation, "Commas are missing in drug description!"
txtdrugdesc1.SetFocus
Exit sub
End If
Per above comment, I don't know how to count the number of commas in
the text box but I suspect the =Len function could be used but I
cannot figure how to use it.
I would be grateful for advice please!
I have a userform where there are two text boxes (drugdesc1 &
drugdesc2) that I want to force 4 commas to be keyed into both fields.
4 commas are MANDATORY in each text box & are used to separate the
type of input within each. ie; brand name, ingredients, strength,
form, pack size. (FYI: Later on, I split these fields into 4 separate
columns based on the comma delimiter.)
When "cmdAdd" command button is clicked, I need to display a msgbox to
advise user and disallow the add.
I imagine that the code (repeated for each text box) that I would put
in the "sub cmdAdd" procedure would go something like this:
If Me.txtdrugdesc1.Value = ' this is the part I need help with.
Perhaps it's the =Len function?
Then
MsgBox "Please key in four commas into Drug Description 1!",
vbExclamation, "Commas are missing in drug description!"
txtdrugdesc1.SetFocus
Exit sub
End If
Per above comment, I don't know how to count the number of commas in
the text box but I suspect the =Len function could be used but I
cannot figure how to use it.
I would be grateful for advice please!