12-07-09, 17:20 #1Registered User
- Join Date
- Oct 2009
Unanswered: Input Mask or Data Validation in VBA?
I am trying to do either input mask or data validation in VBA. What I had originally was a data validation rule and text, but instead of the text box popping up, I would rather flash a hidden label for a couple seconds. So I am trying to do this in VBA but I can't figure it out. Can someone please tell me what it should look like? Here is my code:
(I want it to be 13 digits.....I also tried #############; with the same result.....msgbox NO)
If [Forms]![frm_ScanHU]![enterHU].InputMask = "9999999999999" Then MsgBox "Yes" Else MsgBox "No" End If
12-07-09, 18:07 #2Registered User
- Join Date
- Aug 2009
- Up Nort' Wi
Looks like you're testing the input mask rather than the actual input. If it's always going to be numeric I would do something along these lines:
If len(NumVariable) <>13 then
Dim tmp_chr as string
Dim X as integer
for x = 1 to 13
tmp_chr = mid(NumVariable, x,1)
If tmp_chr Like("#") Then
Psuedocode only, may need to convert the feild variable to a string if it's currently a number format, etc etc.
Sam, hthGood, fast, cheap...Pick 2.