473,789 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autonumber not working

I am using an autonumber as a form id with a SubForms (which
automatically fill the linking fields from the parent into the child).
Occasionally (maybe 5% of the time) the autonumber does not work... it
simple continues to say "(autonumbe r)" and so the child linking field
isn't created. The data entered is in the table but the autonumber id
field is blank so the subform linked data can not be linked and/or
displayed. Anyone have any suggestions?

Apr 3 '06 #1
3 3370
This probably happens when the *main* form is at a new record. Since the
main form's primary key is then null, the foreign key field in the subform
will remain null.

To prevent this happening:
1. Open the subform's table in design view.
2. Select the foreign key field.
3. In the lower pane, set the Required property to Yes for this field.

That prevents the save, but the user does not get the message until they
finish entering the subform record and try to save it. To give them the
message earlier, cancel the BeforeInsert event of the subform if there is no
record in the main form. Example event procedure:

Private Sub Form_BeforeInse rt(Cancel As Integer)
If Me.Parent.NewRe cord Then
Cancel = True
MsgBox "Enter the main form record first."
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Th************ **@yahoo.com> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com...
I am using an autonumber as a form id with a SubForms (which
automatically fill the linking fields from the parent into the child).
Occasionally (maybe 5% of the time) the autonumber does not work... it
simple continues to say "(autonumbe r)" and so the child linking field
isn't created. The data entered is in the table but the autonumber id
field is blank so the subform linked data can not be linked and/or
displayed. Anyone have any suggestions?

Apr 4 '06 #2
I would like to work around getting the error message at all as my end
users freak out and call me if any error message pops up. I don't
understand why it isn't autonumbering sometimes... especially since it
really just started happening randomly. The user clicks a button to
create the record for a particular employee chosen on a previous form,
which opens the form in add mode and automatically fills in the
employee id and the days date in the *main* form portion, but sometimes
the autonumber id does not generate a number and I can't undersand
why.....

Apr 4 '06 #3
To get around the error, you must understand the cause.

If the cause is that the user is entering a subfrorm record when the main
form is at a new record, you must figure out how to stop them.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Th************ **@yahoo.com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
I would like to work around getting the error message at all as my end
users freak out and call me if any error message pops up. I don't
understand why it isn't autonumbering sometimes... especially since it
really just started happening randomly. The user clicks a button to
create the record for a particular employee chosen on a previous form,
which opens the form in add mode and automatically fills in the
employee id and the days date in the *main* form portion, but sometimes
the autonumber id does not generate a number and I can't undersand
why.....

Apr 5 '06 #4

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

Similar topics

12
23778
by: deko | last post by:
Is there a way to reset the AutoNumber sequence? I have several tables that use the AutoNumber field as the Primary Key, and I'd like to somehow do an Import/Export that will make remove the breaks in the sequence. A few breaks in sequence is not a big deal, but I have one table with under 200 records, but the last AutoNumber PK ID field is over 1500 - due to a lot of edits....
33
4322
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and setting default value to a UDF that manages the auto-numbering. Access won't take a UDF as a default value. Okay, I'll use SQL WITHOUT any aggregate functions, for the default value. Access won't do that either. Okay, I create a second...
35
7278
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key start at 51 after the last 50 records are deleted? Thanks! Traci
26
3821
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is assigned to a record that it doesn't change. Occasionally I find that due to corruption or an accidental deletion and restore of a record from a backup the autonumber field needs to be tidied up. So when I create (through AddNew) the autonumber...
2
3863
by: M Fisher | last post by:
Is there a way to get the autonumber of a newly inserted record? I am working with unbound forms, and using an append query to insert a record into a table. I am then using a select query that returns the max ID (the autonumber field) of the table. This gives me the correct number. However, could this go wrong in a multi-user environment. I insert a record, and say it gets ID 10, but before (even thoug it is a split second) I read the...
11
4498
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
4
2354
imrosie
by: imrosie | last post by:
Hello All, (newbie)...I'm working on an Ordering app using the typical tables (customers, orders). I have a Search form to find existing customers prior to entering a new order. On the search form there's a combo control called 'custname' so that when a customer is located, the existing customer name is filled in and the account number goes into the Account control (from an autonumber field called CustomerID from Customer table). The rest of...
5
4610
by: jnice814 | last post by:
I am trying to create an AutoNumber that will begin at a number that I specify. I have followed all instructions in MS Access Help, but it is still not working. I continue getting an error message that 1 record has a validation rule problem, but I cannot figure out what it is. I don't have anything in the validation rule fields on either table. I've checked everything in both tables. What can I be missing? This is very frustrating... I...
6
11763
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the contents of the form is inserted into the MS Access database. The Customer table in the database already has 30 records (with CustomerIDs 1 - 30) in it (from when the database was first created). The CustomerID field in the database is an...
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.