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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd RunSQL automatic confirmation

Status
Not open for further replies.

Thingol

Technical User
Jan 2, 2002
169
Hi All,

I hope this is a simple question:

I have a piece of code that updates a query throught the DoCmd RunSQL command:

Code:
strSQL = ""
For inti = 0 To 2
   Set Q = db.QueryDefs("qrySelectionLabelsUpdate")
   'Update fields for which Gender equals strGender(inti)
   strSQL = "UPDATE qrySelectionLabels SET qrySelectionLabels.Gender = '" & strSalutation(inti) & "' WHERE qrySelectionLabels.Gender = '" & strGender(inti) & "';"
   Q.sql = strSQL
   DoCmd.RunSQL (Q.sql)
Next inti
'Close Querydef
Q.Close

Question 1:
When I run the code, I have to confirm (for each of the three loops) that I actually want to update the query "qrySelectionLabels". Can I force an "OK" for this through code?

Question 2:
Can I update the "Gender" fieldname in the query "qrySelectionLabels" to "Salutation"? I tried using the AS instruction, but get syntax errors; I think I'm using it in the wrong way. How can I achieve this?

Thanks a lot in advance for any help!

Best regards,
Martijn Senden

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Hi

Q.sql = strSQL
docmd.setwarnings false
DoCmd.RunSQL (Q.sql)
docmd.setwarnings true
Next inti

for your second question show what you tried


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top