473,379 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 3919
<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 surname = "" and address1 = "" and town = "" and county...
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 usual address, phone, etc.). The database is...
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, "myinputspec", "tblnames", File, True no autonumber ID is...
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 create a query by making relation to a table & query,...
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, how can I prevent from getting errors when a field...
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 solver it? Bart Access 2003
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 the MSQL express files wont work on thier server so...
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 MyVar=DMax("","MyTable... You can never be...
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 --- userID -- AutoNumber UserInfo -...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.