how to get row just inserted

M

middletree

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top