Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

Auto Numbering

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nigel - 27 Nov 2007 11:17 GMT
I want to be able to increase my ID field for each new record I enter, but I
don't want to use an autonumber field in my table. I have used the following:
ID = Nz(DMax("[id]", "tblNames")) + 1
and put it in the On Current property of the form. The problem is that when
the last field is completed and the user presses Enter, the new record
automatically puts in the new ID number. What I want to do is for the form to
put in the next ID number but only when the 2nd field has data entered in it.

Thanks
Mark A. Sam - 27 Nov 2007 11:27 GMT
Nigel,

Place your code into the AfterUpdate event of the second field.

God Bless,

Mark A. Sam

>I want to be able to increase my ID field for each new record I enter, but
>I
[quoted text clipped - 10 lines]
>
> Thanks
Nigel - 27 Nov 2007 11:44 GMT
Thanks Mark, just what I wanted.

Nigel

> Nigel,
>
[quoted text clipped - 18 lines]
> >
> > Thanks
Rick Brandt - 27 Nov 2007 12:01 GMT
> Thanks Mark, just what I wanted.

That will work as long as you will never have more than one person entering
records at the same time.  If you do you need to use the BeforeUpdate event of
the form and test for the NewRecord property.

Actually you need to test for the NewRecord property the way you are doing it as
well.  Otherwise if someone edits the second field on an existing record the
number will be reassigned.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

croy - 27 Nov 2007 14:26 GMT
>I want to be able to increase my ID field for each new record I enter, but I
>don't want to use an autonumber field in my table. I have used the following:
[quoted text clipped - 3 lines]
>automatically puts in the new ID number. What I want to do is for the form to
>put in the next ID number but only when the 2nd field has data entered in it.

This may not be the best for your situation, but it's worth
a thought...

Use your code to set DefaultValue instead of the Value.
Certainly not foolproof, but if your data-entry folks have
good understanding, and good discipline...

Signature

croy

Keith Wilby - 27 Nov 2007 15:57 GMT
>>I want to be able to increase my ID field for each new record I enter, but
>>I
[quoted text clipped - 15 lines]
> Certainly not foolproof, but if your data-entry folks have
> good understanding, and good discipline...

Default Value, I agree.  I find the best way to implement that code is via a
"new record" command button - set up the form such that the only way to add
a new record is via your command button and save the record as soon as it is
created.  Don't allow users to delete records, allow them to flag them as
deleted and query accordingly.

Keith.
www.keithwilby.com
Rick Brandt - 27 Nov 2007 18:56 GMT
>> I want to be able to increase my ID field for each new record I
>> enter, but I don't want to use an autonumber field in my table. I
[quoted text clipped - 11 lines]
> Certainly not foolproof, but if your data-entry folks have
> good understanding, and good discipline...

Also will not work with multiple users entering records simutaneously.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.