473,666 Members | 2,181 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 3519
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.goo gle.com... 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.goo gle.com...
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.goo gle.com...
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
3965
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 gets changed to "&amp;#10" and doesn't render new lines in the Excel sheet. Can anyone help? Many thanks,
4
2541
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 records(getting it from a select statement) into an temporary table which takes around 22.5 hours. When i execute the query seprately, it talkes only 3 min to complete the exection. The tablespace i am using for temporary table is DMS and it has lots of...
8
1404
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 below: When one of my functions is called, the program works as it is supposed to do, but when I add a line, say for example:
6
4389
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() ; So I tested the three lines of code 1. int *p = new int ; 2. int *p = new int() ;
10
3798
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
1301
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
1549
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) = Right("0000" & CStr(rs!customerID), 5), but how do I affect the layout?
6
1522
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 timestamps, other than my having to whip up a simple parsing routine? My headache is that I use strtotime in a lot of places in a lot of files, and I'd hate to have to add a wrapper everyplace I use it. I wish there were a way to extend strtotime's...
1
1651
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
8362
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7389
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.