Selecting the last field in a table

C

Chris

Hello All,

I am trying to save the value of a primany key as a foreign key in another
table. I would normally do this by linking subforms but the form is looking
good and i have all sorts of stuff linking to it that I don't want to mess
around with.

So I am using an Insert Query to put a value into the master table. Once
this is added, a primary key is created by an autonumber. I would like to
access this primary key and store it in another table.

My first thought would be to do a select query

strSQl = "Select Top 1 SOAdetails " & _
"From tblSOADetails" & _
'"ORDER by SOAdetails Desc" & ";"
runSQL strSQl

I then discovered that I could not run the strSQL with a SELECT argument.

So now I'm trying to access the table by

Set db = CurrentDb
Set rs = db.OpenRecordset("tblSOAdetails", dbOpenDynaset)
rs.findlast (field name) ' field name is wrong argument

I think i could put a listbox on my form invisibly and access the record
from there using the correct findlast argument but I'm sure there must be a
simpler way.

Anybody willing to share one with me?
 
G

Guest

Why not just setup a relations between the two tables and set Cascade Update
Related Fields?
 
C

Chris

I'm doing a section of a databse that will be imported into another
database. That database is not linked so I don't want to link my table.
 

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

Top