Forums
This topic is locked
Session Variable Pass Autonumber Value
Posted 21 years ago
1
has voted
21 years ago Randy Huitema posted:
Hello,I have created an insert page and would like to pass the values to the next page. I have them all working except for the ID field for the record. It is an autonumber in an Access 2000 db.
Is there any way to pass this value?
Replies
Replied 21 years ago
21 years ago Lee Diggins replied:
Hi
If I understand this correctly then the reason the ID value isn't being passed is because the ID value isn't created until the record has been written to the database due to it being an autonumber.
Digga
Sharing Knowledge Saves Valuable Time!!!
If I understand this correctly then the reason the ID value isn't being passed is because the ID value isn't created until the record has been written to the database due to it being an autonumber.
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 21 years ago
21 years ago Randy Huitema replied:
Yes, that is eactly the problem.
Any ideas?
Any ideas?
Replied 21 years ago
21 years ago Lee Diggins replied:
Hi Randy
Seeing you're passing the other values to the next page successfully, you'll need to create a recordset that will retrieve the data based on the values being passed to the next page from your form. A select statement where field1 = formitem1 and field2 = formitem2 etc. Only problem is, are the fields being submitted unique, if not it might be difficult? You could also use select top 1 from etc order by DESC, but this only guarantees you'll get the right record if there's only one person running the insert. You could add a time and date stamp into the database as that's unique and pass that to the next page creating the recordset based on that information. There are other ways too, but I don't work with Access only SQL so I couldn't give you straight answer.
Are you planning to run updates immediately to the newly inserted record then?
Digga
Sharing Knowledge Saves Valuable Time!!!
Seeing you're passing the other values to the next page successfully, you'll need to create a recordset that will retrieve the data based on the values being passed to the next page from your form. A select statement where field1 = formitem1 and field2 = formitem2 etc. Only problem is, are the fields being submitted unique, if not it might be difficult? You could also use select top 1 from etc order by DESC, but this only guarantees you'll get the right record if there's only one person running the insert. You could add a time and date stamp into the database as that's unique and pass that to the next page creating the recordset based on that information. There are other ways too, but I don't work with Access only SQL so I couldn't give you straight answer.
Are you planning to run updates immediately to the newly inserted record then?
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 21 years ago
21 years ago Randy Huitema replied:
Digga,
Since I posted this question, I have thought through all the scenarios you mentioned.
The DateStamp is inserted the same as the AutoNumber.
I am going to pass 2 fields (Name + Address ) as one value, and use it for the Unique record.
Thanks for your help.
Since I posted this question, I have thought through all the scenarios you mentioned.
The DateStamp is inserted the same as the AutoNumber.
I am going to pass 2 fields (Name + Address ) as one value, and use it for the Unique record.
Thanks for your help.
Replied 21 years ago
21 years ago Rammy Nasser replied:
What u need to do is create a sesssion variable that will take the value of the autonumber. Create the variable on the page that does the insert. This will make it exist by the time you hit the next page.....
Replied 21 years ago
21 years ago Ari Yares replied:
How do you create a session variable with the value of the autonumber?
Replied 21 years ago
21 years ago Phil Shevlin replied:
check out the insert with ident extension found right here on DMZ Zone
Replied 21 years ago
21 years ago Owen Eastwick replied:
Here's how to retrieve the value of an Autonumber field on insert: www.drdev.net/article06.htm
In the example shown, once you have the Record Identity stored in the variable varNewID, you can store it in a session variable, for example:
Session("RecordID"
= varNewID
Alternatively you can modify the code to create the Session Variable directly from the returned ID:
Replace this line: varNewID = rsNewID(0)
With this: Session("RecordID"
= rsNewID(0)
Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
In the example shown, once you have the Record Identity stored in the variable varNewID, you can store it in a session variable, for example:
Session("RecordID"

Alternatively you can modify the code to create the Session Variable directly from the returned ID:
Replace this line: varNewID = rsNewID(0)
With this: Session("RecordID"

Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/