Code Examples

Run A Query

acCmdRun

A very long winded way of running a query.

'***************** Code Start *******************
' Code by Terry Wickenden

Sub QueryRun(strPass As String)
  Dim strMsg As String

  On Error GoTo Errhandler

  DoCmd.OpenQuery strPass, acViewDesign
  DoCmd.RunCommand acCmdRun
SubExit:
  Exit Sub
Errhandler:
  Select Case Err.Number
    Case 7874 'probably wrong name for query
      strMsg = strPass & " is not a valid query name."
      strMsg = strMsg & vbCrLf & "Please try again"
      MsgBox strMsg
      Resume SubExit
    Case Else
      strMsg = Err.Number & vbCrLf & Err.Description
      MsgBox strMsg
      Resume SubExit
  End Select
End Sub

'****************** Code End ********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.