Hi all,
Merry Christmas
I ran into something today and I found a way around it by just leaving a blank table "tblTransaction" but I have 6 forms that use this same code (Below)
and just wondering if it is possible to add the following to this or should I have different MakeTranCodes() for each form....?
Existing code is:
Code:
Public Function MakeTransCode() As String
' number from 000000 to 999999
' no 1s or 0s
' starts with T
' cant repeat
Const MAXLOOP = 10000
Randomize
Dim Counter As Long
Dim IsValid As Boolean
Dim s As String
Dim TransactionID As Long
IsValid = False
Counter = 0
While Not IsValid And Counter < MAXLOOP
Counter = Counter + 1
IsValid = True
s = "T" & Format(Int(Rnd * 1000000), "000000")
If InStr(s, "0") <> 0 Or InStr(s, "1") <> 0 Then
IsValid = False
Else
' check if in table
TransactionID = Nz(DLookup("TransactionID", "tblTransaction", "TransCode='" & s & "'"), 0)
If TransactionID <> 0 Then IsValid = False
End If
Wend
If Counter >= MAXLOOP Then
MsgBox "WARNING: MakeTransCode Max Looped"
Exit Function
End If
MakeTransCode = s
End Function
Code I want to replace the code in RED above with:
Code:
TransactionID = Nz(DLookup("TransactionID", "tblTransactionDeposit", "TransCode='" & s & "'"), 0)
TransactionID = Nz(DLookup("TransactionID", "tblTransactionOpenBalance", "TransCode='" & s & "'"), 0)
TransactionID = Nz(DLookup("TransactionID", "tblTransactionPayment", "TransCode='" & s & "'"), 0)
TransactionID = Nz(DLookup("TransactionID", "tblTransactionPurchase", "TransCode='" & s & "'"), 0)
TransactionID = Nz(DLookup("TransactionID", "tblTransactionRF", "TransCode='" & s & "'"), 0)
TransactionID = Nz(DLookup("TransactionID", "tblTransactionTransfer", "TransCode='" & s & "'"), 0)
Sorry for poor description but i am not sure just how to ask this question....
Thanks
Dave