invoicenumber format (1 Viewer)

edojanssen

Registered User.
Local time
Today, 15:35
Joined
Jun 21, 2006
Messages
23
I've build a program for making invoices. The invoicenumbers come from an external program. To lower down the insertion of wrong invoicenumbers would like an inbuild controller on the invoicenumbers.

The invoicenumber begins with the last two digits of the year followed by 71 and a sequence of 4 digits. Example 10710172.

This is what I have right now. But unfortunately is doesn't work. If I use the invoicenumber 10710172 or similar the code goes right to the Else in the code.

PHP:
    Dim iJaarE As Integer
    Dim sJaarE As Integer
    Dim sInputE As String
   
    sInputE = InputBox("Geef het ErBo-faktuurnummer uit Exact op!", "ErBo-faktuurnummer")
    iJaarE = Format(Date, "yyyy")
    sJaarE = Right(CStr(iJaarE), 2)

    If sInputE = sJaarE & "71*" Then
    [Faktuurnr] = sInputE
        Me.ErBo.Value = True
        Me.Refresh
        DoCmd.GoToControl "Datum"
    Else
    MsgBox "Het ingevoerd faktuurnummer is niet juist"
    End If

Who can help me out?

Edo
 
Last edited:

MarkK

bit cruncher
Local time
Today, 06:35
Joined
Mar 17, 2004
Messages
8,199
If you are validating the format of the invoice number and you intend to use the "*" character as a wildcard for pattern matching then you need to use the 'LIKE' operator not '='.
Code:
If sInputE LIKE sJaarE & "71*" Then
 

edojanssen

Registered User.
Local time
Today, 15:35
Joined
Jun 21, 2006
Messages
23
Thanks lagbolt,

Another step forwards with the program. Next problem I encounter is the number of digits. The invoice is 8 digits. But now I also can enter 10711 as invoicenumber. How can I check if the input contains 8 digits?

Edo
 

MarkK

bit cruncher
Local time
Today, 06:35
Joined
Mar 17, 2004
Messages
8,199
Check out the Len() function.
 

edojanssen

Registered User.
Local time
Today, 15:35
Joined
Jun 21, 2006
Messages
23
Thanks lagbolt,

It works perfect.

Code:
If Len(sInputE) <> 8 Then

Edo
 

Users who are viewing this thread

Top Bottom