469,951 Members | 2,352 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

how to get row just inserted

ASP 3 and Access 2000. I have a page which enters a row into a table, and
then enters some other info into another table. Problem is, I need to do the
first one, then obtain the PK, which is an Autonumber, so I can enter it
into the other table.

I know how to do this in SQL Server with identity columns, but this is
Access. (I know Access is not very good, but I have to use it for this
church project.)

Here's my code:

strFName = Replace(Trim(Request.Form("FName")),"'","''")
etc.

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[etc]"
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnection
objConnection.Open
strSQL = "INSERT INTO Personal(etc) "
strSQL = strSQL & "VALUES(etc) "
objConnection.Execute strSQL

So now I need to do a SELECT from the Personal table, then enter that into
the table which consists of 2 fields, both of which are FK's for other
tables (this table was put in to resolve a many-to-many relationship)

FWIW, I'm doing this in a loop; that is, I have a variable number of
checkboxes, and for each one checked by the user, I'll have to insert a row
into this 2nd table. One one entry into the first table, though.

Any help would be appreciated.


Jul 19 '05 #1
2 1878

"middletree" <mi********@htomail.com> wrote in message
news:u5**************@TK2MSFTNGP12.phx.gbl...
ASP 3 and Access 2000. I have a page which enters a row into a table, and
then enters some other info into another table. Problem is, I need to do the first one, then obtain the PK, which is an Autonumber, so I can enter it
into the other table.


http://www.aspfaq.com/show.asp?id=2174

Ray at home
Jul 19 '05 #2
Dang! I usually go to aspfaq first, but didn't do it this time. Thanks!
"Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...

"middletree" <mi********@htomail.com> wrote in message
news:u5**************@TK2MSFTNGP12.phx.gbl...
ASP 3 and Access 2000. I have a page which enters a row into a table, and then enters some other info into another table. Problem is, I need to do

the
first one, then obtain the PK, which is an Autonumber, so I can enter it
into the other table.


http://www.aspfaq.com/show.asp?id=2174

Ray at home

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

66 posts views Thread by mensanator | last post: by
4 posts views Thread by rcamarda | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.