Forums

This topic is locked

Session Variable Pass Autonumber Value

Posted 26 May 2003 15:18:13
1
has voted
26 May 2003 15:18:13 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 29 May 2003 16:39:21
29 May 2003 16:39:21 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!!!
Replied 29 May 2003 17:10:22
29 May 2003 17:10:22 Randy Huitema replied:
Yes, that is eactly the problem.

Any ideas?
Replied 29 May 2003 17:28:33
29 May 2003 17:28:33 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!!!
Replied 29 May 2003 17:45:20
29 May 2003 17:45:20 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.
Replied 29 May 2003 18:49:40
29 May 2003 18:49:40 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 12 Jun 2003 22:58:49
12 Jun 2003 22:58:49 Ari Yares replied:
How do you create a session variable with the value of the autonumber?
Replied 13 Jun 2003 02:17:07
13 Jun 2003 02:17:07 Phil Shevlin replied:
check out the insert with ident extension found right here on DMZ Zone
Replied 13 Jun 2003 02:52:36
13 Jun 2003 02:52:36 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/

Reply to this topic