472,342 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

Detecting when AutoNumber field = NULL

I'm having a problem with a form that uses AutoNumber as the primary
key. I have an Abort button to delete the current record and close the
form. If AutoNumber is assigned, the code executes a SQL statement
that deletes the current record. I need to be able to detect when
AutoNumber is unassigned (a new blank record) so that I can simply
close the form without running the SQL delete statement.

Unfortunately, no tests I can think of can identify when the AutoNumber
field is blank or NULL. Any ideas?

Oct 6 '06 #1
1 3827
<gt*******@gmail.comwrote
I'm having a problem with a form that uses AutoNumber as the primary
key. I have an Abort button to delete the current record and close the
form. If AutoNumber is assigned, the code executes a SQL statement
that deletes the current record. I need to be able to detect when
AutoNumber is unassigned (a new blank record) so that I can simply
close the form without running the SQL delete statement.

Unfortunately, no tests I can think of can identify when the AutoNumber
field is blank or NULL. Any ideas?
Fortunately, you explained _why_ you wanted to determine a Null AutoNumber.
In fact, if you have begun to enter any data in the Record, a number will be
displayed in a Control bound to Autonumber, even though the Record has not
been written.

But, you can accomplish your purpose with the test:

If Me.NewRecord = True Then

Be sure to put code in the BeforeUpdate event to accomplish the
cancellation, because (unless you have other required Fields) closing the
Form will write the dirtied Record.

Caution: Once displayed, that value for the AutoNumber is "used", so
cancelling the Record will not make it available for re-use and avoid the
"gap" in AutoNumbers of a cancelled Record, if that was another purpose of
what you wanted to do.

Larry Linson
Microsoft Access MVP
Oct 6 '06 #2

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

Similar topics

19
by: Gav | last post by:
Hi, At the moment i am checking that all the fields have been filled out, at the moment i am using the following... if firstname = "" and...
0
by: Frances | last post by:
Hi All, I'm having a problem trying to add a record to a simple Access 2000 db (db is very similar to an address book but with more info than the...
3
by: Danny | last post by:
I am doing the TransferText method to import a tab delimited file. I am using a saved specification. DoCmd.TransferText acImportDelim,...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had...
9
by: D. Shane Fowlkes | last post by:
I'm using SQL Server 2000 and on my page, I'm simply creating a SQLDataReader and filling in Labels with the retrieved (single) record. However,...
9
by: AA Arens | last post by:
When I start a new record, the <autonumbering> ID in the field is not updated yet, only when I fill in the first field of that record. How to...
3
by: Richard Finnigan | last post by:
Hi I was wondering if anyone could help me with this problem. I've been using VWD and my webhost ( a shared hosting package) have told me that...
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads...
1
by: BMF | last post by:
Howdy, I am mainly a MySQL user but I have been playing with Access 07 a little bit recently. I created a database with 3 tables. Table ID ---...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.