By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,403 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,403 IT Pros & Developers. It's quick & easy.

Autonumber not working

P: n/a
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 "(autonumber)" 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
Share this Question
Share on Google+
3 Replies


P: n/a
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_BeforeInsert(Cancel As Integer)
If Me.Parent.NewRecord 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*********************@v46g2000cwv.googlegro ups.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 "(autonumber)" 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

P: n/a
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

P: n/a
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.googlegr oups.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 discussion thread is closed

Replies have been disabled for this discussion.