ok folks, I'm gonna try to make as much sense out of this as i can. I had a db written for me so i could cash checks in my small business and keep up with the records of such. However, the person who designed the db has vanished and will no longer support it. I know just enough about access to be dangerous) So, here's my dillemma. I had the db configured to where my receipt numbering worked like this; on today, September 22, 2009, the first receipt number generated is 90922001: (the first 9 being the year, the 09 being the month, the 22 being the day, and 001 being the first check cashed today) (actually the format is yymmdd, but for some reason the 0 doesn't show on the year 09). Here's where my problem begins. One year ago i started using this db. on september 21, 2008 i cashed two checks. (receipt #'s 80921001 & 80921002). yesterday, on september 21, 2009 i cashed a check and it picked up from where the 2008 receipts left off. ie: it numbered the receipt 80921003. I'm gonna post the portion of code that does this. Can someone please look and tell me what is screwed up in here to cause this?
'**If all is OK, now assign sequential number
maxdate = Me.txtcashdate
char2 = Format(Me.txtcashdate, "mmdd")
'===new per jody
Dim xan As String
Dim howsql
Dim rshow
howsql = "Select * from a_datescheck"
Set rshow = CurrentDb.OpenRecordset(howsql)
'Dim dayx As Long
'dayx = DateDiff("d", rshow.lastdate, Now())
If rshow.RecordCount > 0 Then
xan = rshow.nextnumber + 1
Else
xan = Format(Me.txtcashdate, "yymmdd") & "001"
End If
p.s. i noticed that 3 lines down, it shows char2 = Format(Me.txtcashdate, "mmdd"). i tried changing to yymmdd, but it appears that it caused the code to jump to line 15 (xan = Format(Me.txtcashdate, "yymmdd") & "001") because it tries to number everyreceipt as 90921001. which in this case attempts to duplicate a primary key (receipt number) and causes an error. PLEEEEASE HELP!!! much thanks in advance!