Access Vb Code For Calling Queries -
To run an , Append , or Delete query without showing anything to the user, use the .Execute method. This is the "professional" way to handle data.
Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("qryActiveUsers") Do While Not rs.EOF Debug.Print rs!UserName ' Print the value of the "UserName" field rs.MoveNext Loop rs.Close Use code with caution. Copied to clipboard Pro-Tip: Avoid DoCmd.RunSQL Access Vb Code For Calling Queries
If your code crashes before you turn warnings back on, your Access environment will stay "silent" for everything. To run an , Append , or Delete
It does not report exactly why a query failed as clearly as db.Execute . MS Access - execute a saved query by name in VBA To run an
While you might see DoCmd.RunSQL in older tutorials, it is generally discouraged because: