J
johnlute
I'm trying to revise a double click event from a database that I
didn't design. I'm having trouble understanding the logic of the
author. Here's what I have:
Private Sub RDno_DblClick(Cancel As Integer)
Dim WeirdNum As String
Dim WN1 As String
Dim WN2 As Integer
Dim MyNumber As Integer
Dim OKVar As Double
Dim dbs As Database, rst As Recordset
WeirdNum = DLookup("[MaxOfRDno]", "highestrdnum")
WN1 = Left(WeirdNum, 1)
WN2 = Right(WeirdNum, 3)
OKVar = WN2 + 1
If WN2 = 999 Then
MyNumber = Asc(WN1)
WN1 = Chr(MyNumber + 1)
OKVar = 0
End If
[RDno] = WN1 & Format(OKVar, "000")
[YR] = Format(Now, "yy")
'Save the Record so no one else can use it
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
This generates [RDno] values that increment:
A000
A001
A002...
B000
B001
B002...
C000
C001
C002...
We've reached Z999 and it now has nowhere to go. I'm trying to change
it so that it will increment like this:
Z999
AA000
AA001
AA002...
BB000
BB001
BB002...
CC000
CC001
CC002...
If I can do this then I'll eventually get to ZZ999 with nowhere to go.
How can I resolve the first increment challenge of going from "single-
letter, triple-number" to "double-letter, triple-number"?
Would it be possible to code this to go on "forever"? For example,
could the letters continuously increment to triple then quadruple,
etc. with the triple-number simply incrementing 000-999?
Also, while compiling the debugger points to:
Dim dbs As Database, rst As Recordset
and states: User-defined type not defined
I've checked my references and don't see any missing. Any ideas why
this is tripping?
Thanks for any help you might have!
didn't design. I'm having trouble understanding the logic of the
author. Here's what I have:
Private Sub RDno_DblClick(Cancel As Integer)
Dim WeirdNum As String
Dim WN1 As String
Dim WN2 As Integer
Dim MyNumber As Integer
Dim OKVar As Double
Dim dbs As Database, rst As Recordset
WeirdNum = DLookup("[MaxOfRDno]", "highestrdnum")
WN1 = Left(WeirdNum, 1)
WN2 = Right(WeirdNum, 3)
OKVar = WN2 + 1
If WN2 = 999 Then
MyNumber = Asc(WN1)
WN1 = Chr(MyNumber + 1)
OKVar = 0
End If
[RDno] = WN1 & Format(OKVar, "000")
[YR] = Format(Now, "yy")
'Save the Record so no one else can use it
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
This generates [RDno] values that increment:
A000
A001
A002...
B000
B001
B002...
C000
C001
C002...
We've reached Z999 and it now has nowhere to go. I'm trying to change
it so that it will increment like this:
Z999
AA000
AA001
AA002...
BB000
BB001
BB002...
CC000
CC001
CC002...
If I can do this then I'll eventually get to ZZ999 with nowhere to go.
How can I resolve the first increment challenge of going from "single-
letter, triple-number" to "double-letter, triple-number"?
Would it be possible to code this to go on "forever"? For example,
could the letters continuously increment to triple then quadruple,
etc. with the triple-number simply incrementing 000-999?
Also, while compiling the debugger points to:
Dim dbs As Database, rst As Recordset
and states: User-defined type not defined
I've checked my references and don't see any missing. Any ideas why
this is tripping?
Thanks for any help you might have!