Results 1 to 2 of 2
  1. #1
    Airborn is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1

    Access Validationcode

    Hi,



    My name is Michael and i'm getting pretty nervous about a problem i can't seem to solve.

    So i have a field, called Rownumber (rij in dutch as you will see in the example below). It excists out of 2 things. (can't be more)

    Rownumber=from 1 till 7
    Placenumber=A, B or C

    So, it has to look like kinda like this

    1A or 2C or 1B, or 2A, or 7B, or 4A, .......

    so it can't be 4D, or 9A
    1st has to be 1-7 (8,9 & 0 are not possible)
    2nd has to be a letter (A, B or c)


    The mask i have is 0L

    Validation in the tableform is only working half...


    Left([Rij];1) Between 1 And 7

    So i'm able to get the 1st thing right wich is getting that number between 1 & 7....now i'm stuck on that ABC thing...

    Any pro's present?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    Here's a small vba that has the checks to see if left(str,1) is in range 1-7, and
    right(str,1) is in A-C.
    '---------------------------------------------------------------------------------------
    ' Procedure : NumAlpha
    ' Author : Jack
    ' Created : 6/12/2011
    ' Purpose : To check that an incoming string (2 chars long) has a format
    ' RowNum ---- 1 numeric in the range 1-7 and
    ' Place ---- 1 alpha in the range of A-C
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Sub NumAlpha()
    Dim RowNum As String
    Dim Place As String
    Dim sX As String
    On Error GoTo NumAlpha_Error

    sX = "9D" '"1C" ' "1P"
    RowNum = Left(sX, 1)

    If RowNum >= 1 And RowNum <= 7 Then
    Debug.Print sX & " is acceptable"
    Else
    Debug.Print RowNum & " first char is not in valid range 1 -7"
    End If

    Place = Mid(sX, 2, 1)
    If Place = "A" Or Place = "B" Or Place = "C" Then
    Debug.Print sX & " part 2 is A thru C"
    Else
    Debug.Print Place & " is not in A-B-C"
    End If
    On Error GoTo 0
    Exit Sub
    NumAlpha_Error:

    MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure NumAlpha of Module AWF_Related"

    End Sub

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums