|
 |
access thread: Unbound Forms Data Entry
Message #1 by Omar Chaudry <OChaudry@b...> on Mon, 29 Jul 2002 10:03:50 +0100
|
|
Dear All
If I have an unbound form for entering data into a table and user has to
press save to insert the data, how can I then return the PK for the inserted
record which is set to autonumber and obviously the user hasn't entered?
Best regards
Omar
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
Message #2 by "Amy Wyatt" <amyw@c...> on Mon, 29 Jul 2002 15:44:58
|
|
This is one reason I don't use AutoNumbering very often for a Primary Key.
In many cases it is better to do your own auto numbering (i.e. get the
last value and add 1 to it). That way you control the numbering better and
you can use unbound forms for data additions so you can do you quality and
integrity checks before the data is actually added to the database table.
In response to you problem, this is what I would do. If you are using
Access as the database format then it allows you to insert the autonumber
through an append query. Therefore, you can query for the Max of your ID
field in the table the data is going to go into and specify the next ID in
your append query when you go to save the data to the table. That way you
know what the ID is because you created it.
WARNING: If this is a multi-user environment, you need to make sure you
have an error routine that will handle two people trying to add
simultaneously.
If this sounds like what you may want to do, let me know and I will
include some base code regarding this.
Amy
> Dear All
If I have an unbound form for entering data into a table and user has to
press save to insert the data, how can I then return the PK for the
inserted
record which is set to autonumber and obviously the user hasn't entered?
Best regards
Omar
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to
this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
Message #3 by Omar Chaudry <OChaudry@b...> on Mon, 29 Jul 2002 15:57:33 +0100
|
|
Thanks Amy
I thought that might be the case, I am currently using the method you
described i.e. creating one's own sequence numbering. From what you say this
might be the better option anyway.
My only concern was indeed about concurrency, in such situations I guess I
could just trap the error (is it error number 6??) and increment again until
successful save is achieved. Let me know if there is a better way of
handling this please.
Finally on the subject of unbound forms how do you propose modelling a
parent/child relationship (master/sub form) through temp tables on the child
side perhaps (things like Order Lines and Invoice lines)?
Many thanks for your help again.
Omar
-----Original Message-----
From: Amy Wyatt [mailto:amyw@c...]
Sent: 29 July 2002 16:45
To: Access
Subject: [access] Re: Unbound Forms Data Entry
This is one reason I don't use AutoNumbering very often for a Primary Key.
In many cases it is better to do your own auto numbering (i.e. get the
last value and add 1 to it). That way you control the numbering better and
you can use unbound forms for data additions so you can do you quality and
integrity checks before the data is actually added to the database table.
In response to you problem, this is what I would do. If you are using
Access as the database format then it allows you to insert the autonumber
through an append query. Therefore, you can query for the Max of your ID
field in the table the data is going to go into and specify the next ID in
your append query when you go to save the data to the table. That way you
know what the ID is because you created it.
WARNING: If this is a multi-user environment, you need to make sure you
have an error routine that will handle two people trying to add
simultaneously.
If this sounds like what you may want to do, let me know and I will
include some base code regarding this.
Amy
> Dear All
If I have an unbound form for entering data into a table and user has to
press save to insert the data, how can I then return the PK for the
inserted
record which is set to autonumber and obviously the user hasn't entered?
Best regards
Omar
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to
this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
Message #4 by "Amy Wyatt" <amyw@c...> on Tue, 30 Jul 2002 14:17:27
|
|
The ADO duplicate record error number is -2147467259 the DAO duplicate
record error number is 3022.
How I handle unbound forms and parent child relationships, there are
several different senerios. A little more detail as to what you are trying
to accomplish might help to narrow the response. Many times it is best to
save the parent record first so that you have an established referance to
use for the child. However, you can wait but you have to make sure your
code saves and establishes the parent reference before you can save the
child data.
Hope this helps,
Amy
> Thanks Amy
I thought that might be the case, I am currently using the method you
described i.e. creating one's own sequence numbering. From what you say
this
might be the better option anyway.
My only concern was indeed about concurrency, in such situations I guess I
could just trap the error (is it error number 6??) and increment again
until
successful save is achieved. Let me know if there is a better way of
handling this please.
Finally on the subject of unbound forms how do you propose modelling a
parent/child relationship (master/sub form) through temp tables on the
child
side perhaps (things like Order Lines and Invoice lines)?
Many thanks for your help again.
Omar
-----Original Message-----
From: Amy Wyatt [mailto:amyw@c...]
Sent: 29 July 2002 16:45
To: Access
Subject: [access] Re: Unbound Forms Data Entry
This is one reason I don't use AutoNumbering very often for a Primary Key.
In many cases it is better to do your own auto numbering (i.e. get the
last value and add 1 to it). That way you control the numbering better and
you can use unbound forms for data additions so you can do you quality and
integrity checks before the data is actually added to the database table.
In response to you problem, this is what I would do. If you are using
Access as the database format then it allows you to insert the autonumber
through an append query. Therefore, you can query for the Max of your ID
field in the table the data is going to go into and specify the next ID in
your append query when you go to save the data to the table. That way you
know what the ID is because you created it.
WARNING: If this is a multi-user environment, you need to make sure you
have an error routine that will handle two people trying to add
simultaneously.
If this sounds like what you may want to do, let me know and I will
include some base code regarding this.
Amy
> Dear All
If I have an unbound form for entering data into a table and user has to
press save to insert the data, how can I then return the PK for the
inserted
record which is set to autonumber and obviously the user hasn't entered?
Best regards
Omar
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to
this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee. Access to
this
message by anyone else is unauthorised. If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful. Please immediately contact the sender if you have received this
message in error. Thank you.
|
|
 |