Access INSERT problem

Please support our MS Access and FileMaker Pro advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Mar 2005
Posts: 14
Reputation: hippychic43 is an unknown quantity at this point 
Solved Threads: 0
hippychic43 hippychic43 is offline Offline
Newbie Poster

Access INSERT problem

 
0
  #1
Jul 28th, 2005
Heya,

I have a table that has a primary key that is generated automatically by the database, so when I write an SQL statement in my program to insert information into the table, I insert values for every field but the primary key field.

The problem here is that in my program I do not know the value of the primary key field. I was wondering if there was any way I could get an INSERT statement to return the value of the primary key field for the record it has just inserted?

The only way I've found of doing this for the moment is by opening the database connection again, once the INSERT statement has been performed, and doing a SELECT query that selects the primary key from any records that match all of the other information I created the record with. Of course if there is two records with exactly the same information for all of the other fields then I'm screwed. In my application that shouldn't happen, but I don't like that the possibility is there.


Thanks
Cristy
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 104
Reputation: Alvein is an unknown quantity at this point 
Solved Threads: 4
Alvein's Avatar
Alvein Alvein is offline Offline
Junior Poster

Re: Access INSERT problem

 
0
  #2
Jul 29th, 2005
Hi. I think it's not possible. I've looked into my old source code, when I used autogenerated key fields in Access, and I've found I was doing something very similar to what you have to do to get the primary key value.

My advice is to generate the key yourself.
Damn it, I still dream of her....:(
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS Access and FileMaker Pro Forum
Thread Tools Search this Thread



Tag cloud for MS Access and FileMaker Pro
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC