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

ACTION QUERY IN VBA

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
What, if any, is the difference between running an action query the following ways.

Docmd.runsql <string>

and

Currentproject.connection.execute <string>

Just a curious question.
 
I personally, am not sure of ALL the differences but,
the arguments for one.

docmd will not return records affected, or an optional
recordset, if desired.

without turning warnings off, docmd will ask for confirmation,
on EVERY record affected.

Docmd.SetWarnings False
Docmd.RunSQL "UPDATE tblSales SET...WHERE txtAmount > 100"
Docmd.SetWarnings True

Dim intAffected As Integer
CurrentProject.Connection.Execute strSQL,intAffected,129

Debug.Print intAffected 'will show how many records were updated

129, will not return a recordset, thus a quicker execution

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top