Hi all,
I'm having problem generating an unique customer number.
It should always have 7 digits and the 'SSE' prefix (for example 'SSE1234567')
Can you see what's wrong?
I think the Do While construction is not correct...?
I'm having problem generating an unique customer number.
It should always have 7 digits and the 'SSE' prefix (for example 'SSE1234567')
Can you see what's wrong?
Code:
'Generate customer number for SSE customers.
Dim Result
Dim strCustNr As String
strCustNr = "SSE" & Int((9999999 - 1000000 + 1) * Rnd + 1000000)
Result = DLookup("[fldCustomerNr]", "tblDevices", "[fldCustomerNr] = '" & strCustNr & "'")
Do While Not IsNull(Result)
Debug.Print "Duplicate " & strCustNr & " found, generate new customer number."
strCustNr = "SSE" & Int((9999999 - 1000000 + 1) * Rnd + 1000000)
Result = DLookup("[fldCustomerNr]", "tblPassiveDevices", "[fldCustomerNr] = '" & strCustNr & "'")
Loop
Me.fldCustomerNr = strCustNr
I think the Do While construction is not correct...?