I am using the following code to try and update a group of queries that all start with qryBB. It works when I use select queries and print out statements to print out any query results, but I just want to run the group of update queries, not show the user any screens or print out. Can anyone see my error and let me know? Thanks.
Private Sub cmdRunUpdates_Click()
Dim PCIUpdate As Integer
Dim mDb As Database
Dim qry As QueryDef
Dim xQryCtr As Integer
Set mDb = CurrentDb
PCIUpdate = MsgBox("Are you sure?", vbExclamation + vbOKCancel, "'OK' will run the BB PCI queries")
If PCIUpdate = 1 Then
With mDb
DoCmd.SetWarnings False
For xQryCtr = 0 To .QueryDefs.Count - 1
If UCase$(Left(.QueryDefs(xQryCtr).Name, 5)) = "qryBB" Then
DoCmd.OpenQuery .QueryDefs(xQryCtr).Name, acViewNormal, acEdit
DoCmd.Close acQuery, .QueryDefs(xQryCtr).Name
End If
Next
End With
DoCmd.SetWarnings True
Else: End If
Set mDb = Nothing
End Sub
Private Sub cmdRunUpdates_Click()
Dim PCIUpdate As Integer
Dim mDb As Database
Dim qry As QueryDef
Dim xQryCtr As Integer
Set mDb = CurrentDb
PCIUpdate = MsgBox("Are you sure?", vbExclamation + vbOKCancel, "'OK' will run the BB PCI queries")
If PCIUpdate = 1 Then
With mDb
DoCmd.SetWarnings False
For xQryCtr = 0 To .QueryDefs.Count - 1
If UCase$(Left(.QueryDefs(xQryCtr).Name, 5)) = "qryBB" Then
DoCmd.OpenQuery .QueryDefs(xQryCtr).Name, acViewNormal, acEdit
DoCmd.Close acQuery, .QueryDefs(xQryCtr).Name
End If
Next
End With
DoCmd.SetWarnings True
Else: End If
Set mDb = Nothing
End Sub