View Full Version : Solved: Run SQL Command
akn112
09-04-2007, 12:38 PM
Hi,
Im having trouble with my Run Sql command. My code is as follows:
strsql = "UPDATE tblAcknowledgement, tblUserInformation SET tblAcknowledgement.[Requester] =""" & requester & """ WHERE tblAcknowledgement.[User Id] = """ & uaUserAccess.UserId & """"
DoCmd.RunSQL strsql
but when i run this, it asks me if i want to update like 10000 records. The table im updating (tblAcknowledgement) only has 500 records. and i've used msgboxes to check that the UserId is valid. Can't figure it out :banghead:
asingh
09-04-2007, 06:41 PM
Hi,
You query shows.that you are trying to UPDATE two tables....tblAcknowledgement and tblUserInformation. And as per your condition if tblAcknowledgement. = """ & uaUserAccess.UserId & """" this query will update table tblAcknowledgement.requestor to "requestor" , [U]AND and also update all records in tblUserinformation.
Probably tblUserinformation has 10000 - 500 records....!
Also try to pass variables in queries like this:
' " & variable_name & " '
regards,
asingh
akn112
09-05-2007, 10:28 AM
Hey man~ works now! thanks a bunch. Could you combine the update with select?
select blah blah
update blah blah
where blah blah
asingh
09-06-2007, 03:51 AM
Hi,
UPDATE queries have the following format:
UPDATE TABLE NAME SET COLUMN NAME WHERE CONDITION
A select cannot be run before it..!
akn112
09-07-2007, 05:08 AM
damn...i tried another one and it's giving me problems...why am i so bad at these queries??? Can someone help me out on the syntax problem w/ :
strsql = "INSERT INTO tblRequesterHistory(MPId, MPName, Requester)" & _
"Values( " & txtMPID.Value & ", '" & txtMPName.Value & "', '" & txtRequesterEmail.Value & "'"
i must have checked the parameter names at least 20 times. MPId is number, where MPName and Requester are both text. :stars:
akn112
09-07-2007, 05:59 AM
stupid me...kept in looking in all the wrong places
strsql = "INSERT INTO tblRequesterHistory(MPId, MPName, Requester)" & _
"Values( " & txtMPID.Value & ", '" & txtMPName.Value & "', '" & txtRequesterEmail.Value & "')"
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.