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.

Create a field where a new number appears when the form is opened

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morgan - 08 Nov 2007 15:42 GMT
I am trying to create a field that will have a number and I want to set that
field to have the number change each time the form is opened.  Each form must
have a unique number.  I know how to do this with a date field but figure out
how to do this when the field just contains a number.  Any ideas?
ruralguy - 08 Nov 2007 16:05 GMT
Have you looked at the DMax() function?

>I am trying to create a field that will have a number and I want to set that
>field to have the number change each time the form is opened.  Each form must
>have a unique number.  I know how to do this with a date field but figure out
>how to do this when the field just contains a number.  Any ideas?

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Steve McLeod - 08 Nov 2007 16:10 GMT
It sounds like this number is NOT bound to a field in a table so you are not
talking about an autonumber key.  It isn't clear if you want to increment
whenever the form is opened or you want a count of the open instances of the
same form.

Something like this in the form's onOpen event might work for the first
requirement:
lngSeqNum = Nz(DMax("SeqNum","tblSeqNum"),0) +1
CurrentDb.Execute "UPDATE tblSeqNum SET tblSeqNum.SeqNum = " & lngSeqNum & "
WHERE tblSeqNum.SeqNum = " & lngSeqNum-1, DAO.dbFailOnError

tblSeqNum has one row with one column named "SeqNum" with an initial value
of zero.

If you have multiple users each sharing the same database via linking then
you will have to deal with collisions and this simple solution will get
complicated.

Multiple instances of the same form in complex and counting them is another
level of complexity, but this can be done.
Signature

Pictou

> I am trying to create a field that will have a number and I want to set that
> field to have the number change each time the form is opened.  Each form must
> have a unique number.  I know how to do this with a date field but figure out
> how to do this when the field just contains a number.  Any ideas?
 
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.