code_junkie

Managing and debugging SQL queries in MS Access

Nov 13th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. NO: DoCmd.RunSQL ("SELECT ...")
  2. YES: strSQL = "SELECT ..."
  3. DoCmd.RunSQL (strSQL)
  4.  
  5. Debug.Print strSQL
  6. Stop
  7.  
  8. strSQL = "SELECT wazzle FROM bamsploot" [underscore]
  9. & vbCrLf & "WHERE 1 > 2"
  10.  
  11. VBA > QBE (described above) > Notepad (for global replace)
  12. Notepad > QBE (for checking, troubleshooting) > VBA
  13.  
  14. Dim myQuery as string, _
  15. rsADO as ADODB.recorset
  16.  
  17. rsADO = new ADODB.recordset
  18. myQuery = getSQLQuery(myId_Query)
  19.  
  20. 'if my query retunrs a recordset'
  21. set rsADO = myADOConnection.Execute myQuery
  22. 'or, if no recordset is to be returned'
  23. myADOConnection.Execute myQuery
  24.  
  25. set rsADO = myADOConnection.execute "dbo.myViewName"
Add Comment
Please, Sign In to add comment