473,508 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DMax fails to Increment beyond "10"

I have a database with an input form. The field "DailyID" on the form
is to increment automatically with each new entry, then reset itself
back to "1" at midnight and/or the change of date.

However, the DAILYID increments automatically to "10" just fine, but
does not go beyond "10" until the date changes.

I have the following code in my form's CURRENT event:

Private Sub Form_Current()

Dim datCur As Date
Dim datMax As Date
Dim intDailyID As Integer

datCur = Me!DateIn
datMax = Nz(DMax("DateIn", "Documents"), Date)

If Me.NewRecord Then
If datCur = datMax Then
intDailyID = Nz(DMax("[DailyID]", "Documents", "[DateIn]=
#" & Me!DateIn & "#"), 0) + 1

Else
intDailyID = 1
End If

Me!DailyID = intDailyID

End If

End Sub
Any clues/ideas how I can solve this? I'm running Access 2002 (XP) on
a network.
Thanks in advance!
Nov 12 '05 #1
3 3516
TC
This probably does not solve your problem, but:

(1) The Current event is not particular appropriate for what you are doing.
I would use the form level BeforeUpdate event, testing for Me.NewRecord.
That event fires when all the data has been entered, & the user has asked to
save the record.

(2) This code is not very safe: "[DateIn]=#" & Me!DateIn & "#"
The #...# format requires the date to be in U.S. (month/day/year) format,
regardless of your PC's settings<. With your code, you can't be certain that DateIn will be the right format. Use a Format$() function to convert
the date to month/day/year format for use in the SQL statement.

HTH,
TC
"Scott" <he*************@yahoo.com> wrote in message
news:8e**************************@posting.google.c om... I have a database with an input form. The field "DailyID" on the form
is to increment automatically with each new entry, then reset itself
back to "1" at midnight and/or the change of date.

However, the DAILYID increments automatically to "10" just fine, but
does not go beyond "10" until the date changes.

I have the following code in my form's CURRENT event:

Private Sub Form_Current()

Dim datCur As Date
Dim datMax As Date
Dim intDailyID As Integer

datCur = Me!DateIn
datMax = Nz(DMax("DateIn", "Documents"), Date)

If Me.NewRecord Then
If datCur = datMax Then
intDailyID = Nz(DMax("[DailyID]", "Documents", "[DateIn]=
#" & Me!DateIn & "#"), 0) + 1

Else
intDailyID = 1
End If

Me!DailyID = intDailyID

End If

End Sub
Any clues/ideas how I can solve this? I'm running Access 2002 (XP) on
a network.
Thanks in advance!

Nov 12 '05 #2

"Scott" <he*************@yahoo.com> wrote in message
news:8e**************************@posting.google.c om...
I have a database with an input form. The field "DailyID" on the form
is to increment automatically with each new entry, then reset itself
back to "1" at midnight and/or the change of date.

However, the DAILYID increments automatically to "10" just fine, but
does not go beyond "10" until the date changes.


Sounds like DAILYID is a text field. Once you get to 9 you get stuck there
because the text string "10" is actually less than 9.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #3
you rock. i just changed the field in my table to number from text and
bingo...11 12 13... thanks.
Rick Brandt wrote:
"Scott" <he*************@yahoo.com> wrote in message
news:8e**************************@posting.google.c om...
I have a database with an input form. The field "DailyID" on the form is to increment automatically with each new entry, then reset itself back to "1" at midnight and/or the change of date.

However, the DAILYID increments automatically to "10" just fine, but does not go beyond "10" until the date changes.
Sounds like DAILYID is a text field. Once you get to 9 you get stuck

there because the text string "10" is actually less than 9.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3933
by: st | last post by:
Hi, I'm using xmlDocument.Save(xmlTextWriter) to create an Excel-readable file. All works well, except where I've replaced the carriage return chars in the .innertext to XML-compliant " "; It...
4
2538
by: WantedToBeDBA | last post by:
Hi Friends, I am running a stored procedure in Windows 2000 box (version 8.1.0) and i am getting following error in db2diag.log repeatly. The scenerio is as follows. I am inserting 55000...
8
1397
by: Maarten | last post by:
Hello, I'm a software engineer for a Dutch company and I am working on the improvement of a already made program and I've found a very curious problem. It consists of two parts, explained...
6
4382
by: peter.xiau | last post by:
I found that std::vector<int> v(10) ; will automatically initiallize every elem to 0 in the vector, I check the source code (VS.NET2003), and I found a line of code like this *T = new T() ; ...
10
3775
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%f",&f); printf("The float is %10.5f\n",f); return 0; }
6
1299
by: Daniel Austria | last post by:
Sorry, how can i convert a string like "10, 20, 30" to a list what i can do is: s = "10, 20, 30" tmp = '' l = eval(tmp)
3
1535
by: Nevyn | last post by:
How do I do that? Turning the layout from the customerID-number "10205" into looking like "10 205"? I've just incresed it from four digits to five, and it looks like this: lsvItem.SubItems(1) =...
6
1507
by: Brian Kendig | last post by:
I'm working with dates in several formats including 'yyyy MMM dd', but strtotime doesn't recognize this format and returns FALSE. Is there a direct way to convert times from this format into...
1
1646
by: charliemears | last post by:
Hi there... How can I limit search results so that there is a "Next 10" and "Previous 10"? thanks for any reply....
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7332
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.