determine gender from Identity number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    determine gender from Identity number

    I got this from a website for South Africa about gender and identity number: there are 13 characters in total
    If 7th character (from left) of the string(ID) is between 0 and 4 the person is female, and between 5 and 9 that person is male .
    How can i get this in a txtbox of a form.
    Table = cyclist
    form = CyclistF
    Identity number field = IdNo (where identity number is captured)
    gender txtbox = gendertype (where it must state male or female depending on 7th digit of identity number in IDNo field
    I also have a field called "Gender" in this table if it can be used or i will copy it across from txtbox.
    pls help
    they had this code on the website
    Code:
    function check_gender_and_id($gender,$idnumber)
    {
    if (($gender == "male" && $idnumber[6] >= 5 && $idnumber[6] <= 9) || ($gender="female" && $idnumber[6] >= 0 && $idnumber[6] <= 4))
    {
    return true;
    }
    return false;
    }
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #2
    this is more code i found but where would one put it on form?
    Code:
    Function CheckIDNumber(ByVal sIDNommer)
    If sIDNommer = "1111111111111" Or sIDNommer = "6666666666666" Then
    Return False
    Exit Function
    Else
    If sIDNommer.ToString.Substring(2, 2) > 12 Or sIDNommer.ToString.Substring(4, 2) > 31 Then
    Return False
    Exit Function
    Else
    If sIDNommer.ToString.Substring(2, 2) = 2 And sIDNommer.ToString.Substring(4, 2) > 29 Then
    Return False
    Exit Function
    Else
    End If
    End If
    End If
    Dim idNo
    Dim a As Integer = 0
    Dim b As Integer = 0
    Dim c As Integer = 0
    Dim d As Integer = -1
    Dim sIDNom As String = ""
    Dim iVal As Integer = 0
    If Len(sIDNommer) <> 13 Then
    CheckIDNumber = False
    Else
    For i = 1 To Len(sIDNommer)
    sIDNom = sIDNom & Mid(sIDNommer, i, 1) & ":"
    Next
    idNo = Split(sIDNom, ":")
    
    For i = 0 To 5
    iVal = i * 2
    On Error Resume Next
    a = a + CInt(idNo(iVal))
    Next
    b = 0
    For i = 0 To 5
    iVal = 2 * i + 1
    b = b * 10 + CInt(idNo(iVal))
    Next
    
    b = b * 2
    c = 0
    Do
    c = c + (b Mod 10)
    b = Fix(b / 10)
    Loop While b > 0
    c = c + a
    d = 10 - (c Mod 10)
    If (d = 10) Then d = 0
    CheckIDNumber = d
    If d = CInt(idNo(12)) Then
    CheckIDNumber = True
    Else
    CheckIDNumber = False
    End If
    End If
    End Function

    Comment

    • dsatino
      Contributor
      • May 2010
      • 393

      #3
      set the textbox controlsource to

      Code:
      =IIF(mid([idno],7,1) between 0 and 4,"Female","Male")

      Comment

      • neelsfer
        Contributor
        • Oct 2010
        • 547

        #4
        short and sweet - thx it works!!!!!!!!

        Comment

        Working...