Verify Format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 2D Rick

    Verify Format

    I open a InputBox for specific formatted data and pass return to a
    variable.
    The format and length remain constant: yyCC looks like 05MR
    Is there a quick way to verify the input meets the format requirement.
    Done in VBA using Access2003
    Rick

  • Salad

    #2
    Re: Verify Format

    2D Rick wrote:[color=blue]
    > I open a InputBox for specific formatted data and pass return to a
    > variable.
    > The format and length remain constant: yyCC looks like 05MR
    > Is there a quick way to verify the input meets the format requirement.
    > Done in VBA using Access2003
    > Rick
    >[/color]
    It looks like an input mask.

    You know that the length needs to be at least 2 since the last 2 chars
    are optional. You also know that the length can't be greater than 4

    Do you want to accept years in 1900? As in 1999? (I'll assume NO) Do
    you want to accept years greater than the current year? (I'll assume NO)

    The first 2 digits should be numeric...0-9

    Dim blnOK As Boolean
    If Len(var) >= 2 or Len(var) <= 4 And IsNumeric(Left( var,1)) And _
    IsNumeric(Mid(v ar,2,1)) Then

    'verify year is less/equal to current year...only allows
    'year 2000 and above.
    IF Cint(Left(var,2 )) <= Cint(Format(Dat e,"yy")) Then
    blnOK = True
    Endif
    Endif
    If not blnOK then
    msgbox "Incorrect format!"
    else
    'process it.
    endif

    Comment

    Working...