Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Where

Status
Not open for further replies.

awalli6i

Programmer
Aug 20, 2001
4
AU
I am trying to do a Access to SQL convert. I need to pull information into the new database but to do it need to make sure that the information is for that person...

sSql = "Insert into PRemp_Employee (PRempDateOfBirth) Where PRempEmployeeCode = " & code & " values ('" & newdate & "') "
newdate = the old access date converted
code is the old employee code from access

Can you tell me why this won't work ?
 
I believe you need to switch around where and values as follows:

sSql = "Insert into PRemp_Employee (PRempDateOfBirth)
values ('" & newdate & "') "
Where PRempEmployeeCode = " & code & "




"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
Mmm, I messed up the quotation marks in copy & pasting, so here's it again, this time correctly:

sSQL = "INSERT INTO Premp_Employee (PRempDateOfBirth) VALUES ('" & newdate & "') WHERE PRempEmployeeCode = '" & code & "'"


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 

If you are trying to update a column in an existing record use an UPDATE query rather than an INSERT query. The SQL INSERT statement that you have have doesn't work because INSERT means "create a new record" and you include a where clause which means "fid an existing record." Can you see the conflict?

sSQL = "UPDATE Premp_Employee SET PRempDateOfBirth = '" & newdate & "' WHERE PRempEmployeeCode = '" & code & "'"
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top