Results 1 to 2 of 2
  1. #1
    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"
    MsgBox "No"
    End If

  2. #2
    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
    next x
    End If
    End If

    Psuedocode only, may need to convert the feild variable to a string if it's currently a number format, etc etc.

    Sam, hth
    Good, fast, cheap...Pick 2.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts