G
Guest
I have a dialog box that has 3 list boxes that are multi select, plus and/or
choices between them that supplies my query, 'qryPickAChecker', then should
run my query. The code seems to be hanging up at this area
cat.Views.Append "qryPickAChecker", cmd
and it gives me:
run-time error '-2147217816 (80040e68)': Object 'qryPickAChecker' already
exists.
I'm am stuck and don't know what to do to fix this. Here is my code to that
point.
Private Sub cmdOK_Click()
Dim blnQueryExists As Boolean
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.View
Dim varItem As Variant
Dim strLast As String
Dim strFirst As String
Dim strCkrCDSID As String
Dim strFirstCondition As String
Dim strCkrCDSIDCondition As String
Dim strSQL As String
' Check for the existence of the stored query
blnQueryExists = False
Set cat.ActiveConnection = CurrentProject.Connection
For Each qry In cat.Views
If qry.Name = "qryPickAChecker" Then
blnQueryExists = True
Exit For
End If
Next qry
' Create the query if it does not already exist
If blnQueryExists = False Then
cmd.CommandText = "SELECT * FROM tblChecker"
cat.Views.Append "qryPickAChecker", cmd
End If
Application.RefreshDatabaseWindow
' Turn off screen updating
DoCmd.Echo False
' Close the query if it is already open
If SysCmd(acSysCmdGetObjectState, acQuery, "qryPickAChecker") =
acObjStateOpen Then
DoCmd.Close acQuery, "qryPickAChecker"
End If
choices between them that supplies my query, 'qryPickAChecker', then should
run my query. The code seems to be hanging up at this area
cat.Views.Append "qryPickAChecker", cmd
and it gives me:
run-time error '-2147217816 (80040e68)': Object 'qryPickAChecker' already
exists.
I'm am stuck and don't know what to do to fix this. Here is my code to that
point.
Private Sub cmdOK_Click()
Dim blnQueryExists As Boolean
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.View
Dim varItem As Variant
Dim strLast As String
Dim strFirst As String
Dim strCkrCDSID As String
Dim strFirstCondition As String
Dim strCkrCDSIDCondition As String
Dim strSQL As String
' Check for the existence of the stored query
blnQueryExists = False
Set cat.ActiveConnection = CurrentProject.Connection
For Each qry In cat.Views
If qry.Name = "qryPickAChecker" Then
blnQueryExists = True
Exit For
End If
Next qry
' Create the query if it does not already exist
If blnQueryExists = False Then
cmd.CommandText = "SELECT * FROM tblChecker"
cat.Views.Append "qryPickAChecker", cmd
End If
Application.RefreshDatabaseWindow
' Turn off screen updating
DoCmd.Echo False
' Close the query if it is already open
If SysCmd(acSysCmdGetObjectState, acQuery, "qryPickAChecker") =
acObjStateOpen Then
DoCmd.Close acQuery, "qryPickAChecker"
End If