Solved

Blank records question

Posted on 2003-11-18
8
277 Views
Last Modified: 2012-08-14
I am using "DoCmd.RunCommand acCmdUndo"  on a button that closes my form to prevent blank or incomplete records from being added.  The only problem I have is my UID is AutoNumbered, and everytime this button is pressed a UID gets deleted (ex. if users start to enter a record, then press the "Close Form", blank record does not get saved - GOOD - but the particular UID that would have been assigned to that record gets deleted - BAD - which throws the sequence off.  If, for instance, user completes record 23, starts to enter record 24 but does not complete it and instead closes the form, record 24 dissappears completely and next time user will start at record 25.)

Is there any particular way to combat this problem?  

Thanks in advance.  Please let me know if this needs further explaining.

IPT
0
Comment
Question by:iptrader
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 32

Accepted Solution

by:
jadedata earned 100 total points
ID: 9773566
Hey iptrader!

  This is a natural function of the AutoNumber and Undo,  once used and trashed, its gone...
  The only cure for this is to compact the database that the table is located in IMMEDIATELY after the autonumber gets trashed.  Access would "recycle" the numbers, re-beginning at the highest number in the current recordset.
  (this is normally NOT thought of as an acceptable solution,...)

  You could use an unbound form to put data into and only commit this data to the table if the user confirms that it is good to go.
  This would prevent the Creation/Trashing of the autonumbers as only good records would be put into the table.
 
Questions?
 
regards
Jack
0
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 100 total points
ID: 9773606
As you have found out, Autonumber really was never intended to be seen by or have much value for end users but is useful as an artificial PK (please don't get started Jack started :-). If you really need a sequential number you are better off writing a custom function to generate it rather than trying to use Autonumber for this purpose.

Steve
0
 
LVL 23

Expert Comment

by:heer2351
ID: 9773619
An autonumber field should *never* have a meaning, it should only be used to uniquely identify a record. Your problem is just an example of why an autonumber field should not have a meaning.
0
 

Author Comment

by:iptrader
ID: 9773642
The UID is not seen by the users, it is only used for my purposes.  It's more of an annoyance than anything else.

IPT
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 23

Assisted Solution

by:heer2351
heer2351 earned 100 total points
ID: 9773658
Sorry Steve did not see your comment before I posted but as you can see I fully agree with your comment. BTW JDettman made an excellent function for this purpose, see:

http://www.experts-exchange.com/Databases/MS_Access/Q_20092292.html
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9773670
I'd say let it be then...  The element has no value other than possibly retrieving a specific record later using this id to find it.
0
 

Author Comment

by:iptrader
ID: 9773735
Thank you for your comments!  Jack, I think I'll take your suggestion, it is becoming more trouble than it's worth.

Best to all,

IPT
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9773775
Thanx for the question!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now