AccessBeginner
Registered User.
- Local time
- Today, 14:53
- Joined
- Mar 22, 2009
- Messages
- 16
ok, I have a database which has a table called Constituents
There is a primary key called ContactID which is a simple Autonumber
I make a reference number (RefNo) from this which is given to each Constituents Manual Case Folder.
The reference number takes the format.... AR/10/C/585
Where the AR/ portion is constant
the 10 is taken from the last two digits of the current year
The /C/ is constant
and the 585 is the ContactID or autonumber
This is all done on the form when the user leaves (exits) the Full Name field.
(Exit Full Name field) Code is...
Private Sub FullName_Exit(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![ContactID] = Nz(DMax("[ContactID]", "Constituents"), 0) + 1
Me![RefNo] = ("AR/" & (Right(Year(Date), 2)) & "/C/" & [ContactID])
End If
End Sub
Now the problem is, if the user deletes a record (lots of reasons, may have a duplicate file or summat, and realises after it has been generated a ref), then the autonumber runs on and the case numbers get a gap (eg next one might be 590 when really it should be 588, etc).
I was thinking, if I could trim the last 3 digits from the actual reference field (RefNo) - put them into a new table column (lets call it TempNumber) and then I could use this as the basis of my RefNo calculation, code as below then....
Private Sub FullName_Exit(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![TempNumber] = Nz(DMax("[TempNumber]", "Constituents"), 0) + 1
Me![RefNo] = ("AR/" & (Right(Year(Date), 2)) & "/C/" & [TempNumber])
End If
End Sub
Problem is...
I have no idea how to make this TempNumber column and get the data in there that I need.
I know this is simple stuff, but I use access once or twice a year, and I never get to the bottom of things, or the time to investigate them properly
Any help appreciated, and I'll answer any questions you may have from my poor effort at explanation.
*off to hide to await being told he is as stupid as he thinks he is*
There is a primary key called ContactID which is a simple Autonumber
I make a reference number (RefNo) from this which is given to each Constituents Manual Case Folder.
The reference number takes the format.... AR/10/C/585
Where the AR/ portion is constant
the 10 is taken from the last two digits of the current year
The /C/ is constant
and the 585 is the ContactID or autonumber
This is all done on the form when the user leaves (exits) the Full Name field.
(Exit Full Name field) Code is...
Private Sub FullName_Exit(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![ContactID] = Nz(DMax("[ContactID]", "Constituents"), 0) + 1
Me![RefNo] = ("AR/" & (Right(Year(Date), 2)) & "/C/" & [ContactID])
End If
End Sub
Now the problem is, if the user deletes a record (lots of reasons, may have a duplicate file or summat, and realises after it has been generated a ref), then the autonumber runs on and the case numbers get a gap (eg next one might be 590 when really it should be 588, etc).
I was thinking, if I could trim the last 3 digits from the actual reference field (RefNo) - put them into a new table column (lets call it TempNumber) and then I could use this as the basis of my RefNo calculation, code as below then....
Private Sub FullName_Exit(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![TempNumber] = Nz(DMax("[TempNumber]", "Constituents"), 0) + 1
Me![RefNo] = ("AR/" & (Right(Year(Date), 2)) & "/C/" & [TempNumber])
End If
End Sub
Problem is...
I have no idea how to make this TempNumber column and get the data in there that I need.
I know this is simple stuff, but I use access once or twice a year, and I never get to the bottom of things, or the time to investigate them properly
Any help appreciated, and I'll answer any questions you may have from my poor effort at explanation.
*off to hide to await being told he is as stupid as he thinks he is*