Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calculation assistance please (A2K)

    Hi,

    In the air freight industry we use an Air Waybill number to ship goods, this consists of 3 numbers or letters then a separator and then 8 numbers. Most airlines these days belong to IATA who have certain rules about the way an air waybill is calculated. A number I have used is 125-58325676, the rules are that a number must always increase by 11 but cannot finish with 7, 8 or 9, when a number ends in 6 it reverts to 0, for example

    125-58325676
    125-58325680
    125-58325691

    etc.

    That's the easy part over. To test if the number is an IATA issued number you have to divide the first 7 of the last 8 by 7, what's left over will always be the last number (number 8) for the air waybill, the sum therefore using the first number I gave 58325676 would be

    58 / 7 = 8 (leaves 2) 23 / 7 = 3 (leaves 2) 22 / 7 = 3 (leaves 1) 15 / 7 = 2 (leaves 1) 16 / 7 = 2 (leaves 2) 27 / 7 = 3 (leaves 6) and as you can 6 is the indeed the last number of the air way bill. If any one can help how do I.

    a. In a text box on my form make that calculation, ignoring any 4 preceding numbers or letters or dashes, i.e. 125-

    b. If it doesn't calculate right because the user input say a 5 at the end instead of a 6 would an ordinary validation rule asking 'This is not an IATA number do you wish to continue' YES / NO let them choose if the continue with the wrong number (I actually want them to able to continue by choice because to complicate matters not all airlines are IATA affiliated).

    On a different matter has anybody noticed Woody's frequent facts about Camels, I am getting a little concerned about life in Chiang Mei or where ever he is hanging out in Thailand.

    TIA

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  2. #2
    New Lounger
    Join Date
    Jan 2001
    Location
    Vermont
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: calculation assistance please (A2K)

    Here - l implemented your algorithm for you. It's ugly and would better have been done with a little recursive routine, but I didn't have enough neurons to spare this morning.

    Call the IsIATAWayBill routine with the full way bill (xxx-yyyyyyyy) and you will get back a TRUE if it is a way bill and false if it's not.

    Function IsIATAWayBill(strWayBillNumber As String) As Boolean
    Dim strWBN As String
    Dim intCheckDigit As Integer

    If Len(strWayBillNumber) <> 12 Then
    IsIATAWayBill = False
    Exit Function
    ElseIf Mid(strWayBillNumber, 4, 1) <> "-" Then
    IsIATAWayBill = False
    Exit Function
    Else
    strWBN = Mid(strWayBillNumber, 5, 7)
    intCheckDigit = ((((((((((Left(strWBN, 2) Mod 7) & Mid(strWBN, 3, 1)) Mod 7) & Mid(strWBN, 4, 1)) Mod 7) & _
    Mid(strWBN, 5, 1)) Mod 7) & Mid(strWBN, 6, 1)) Mod 7) & Right(strWBN, 1)) Mod 7
    If intCheckDigit = Right(strWayBillNumber, 1) Then
    IsIATAWayBill = True
    Else
    IsIATAWayBill = False
    End If
    End If
    End Function

  3. #3
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: calculation assistance please (A2K)

    Thnaks Jordan, a little more help though please. I assume that this should go in the EventProcedure for After update but nothing happens when I put in a false number, I then tried it OnExit with a false number but it just carried on. I am obviously doing something wrong but could you tell me what.

    Thanks

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  4. #4
    Star Lounger
    Join Date
    Sep 2001
    Location
    SC, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: calculation assistance please (A2K)

    You just need to add a little more code to the function telling Access what to do when Jordan's code is true, and what to do when it is false. In your case you could simply exit the function when it is true, but, if it's false, send your msgbox, which will warn the user.

  5. #5
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: calculation assistance please (A2K)

    Thanks Willy

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

Posting Permissions

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