D
DEI
I am trying to open an ADODB recordset with the following code
Dim SQL As String
Dim Conn As ADODB.Connection
Dim rss As New ADODB.Recordset
Set Conn = CurrentProject.Connection
'Source table (Query1)
Select Case STAFF
Case "ALL"
SQL = "SELECT AUDIT.ADATE, AUDIT.STAFFID, AUDIT.AUDITID, AUDIT.ACTID,
AUDIT.TIME " & _
"FROM AUDIT " & _
"WHERE (((AUDIT.LOCID) = " & ASC & ")) " & _
"ORDER BY AUDIT.ADATE, AUDIT.STAFFID, AUDIT.TIME;"
Case "RN"
SQL = "SELECT AUDIT.ADATE, AUDIT.STAFFID, AUDIT.AUDITID, AUDIT.ACTID,
AUDIT.TIME " & _
"FROM STAFF INNER JOIN AUDIT ON STAFF.STAFFID = AUDIT.STAFFID "
& _
"WHERE (((AUDIT.LOCID) = " & ASC & ") And ((STAFF.POSITION) = '"
& STAFF & "')) " & _
"ORDER BY AUDIT.ADATE, AUDIT.STAFFID, AUDIT.TIME;"
End Select
'Open source table
rss.Open SQL, Conn, adOpenKeyset, adLockOptimistic
When I use the first SQL statement, the recordset opens fine. When I use
the second (which is very similar, but has a join) I get the following
run-time error: Method 'Open' of object "-Recordset' failed. I can not
figure out what the problem is. Do I need to use different arguments for the
Open method?
Thanks in advance.
DEI
Dim SQL As String
Dim Conn As ADODB.Connection
Dim rss As New ADODB.Recordset
Set Conn = CurrentProject.Connection
'Source table (Query1)
Select Case STAFF
Case "ALL"
SQL = "SELECT AUDIT.ADATE, AUDIT.STAFFID, AUDIT.AUDITID, AUDIT.ACTID,
AUDIT.TIME " & _
"FROM AUDIT " & _
"WHERE (((AUDIT.LOCID) = " & ASC & ")) " & _
"ORDER BY AUDIT.ADATE, AUDIT.STAFFID, AUDIT.TIME;"
Case "RN"
SQL = "SELECT AUDIT.ADATE, AUDIT.STAFFID, AUDIT.AUDITID, AUDIT.ACTID,
AUDIT.TIME " & _
"FROM STAFF INNER JOIN AUDIT ON STAFF.STAFFID = AUDIT.STAFFID "
& _
"WHERE (((AUDIT.LOCID) = " & ASC & ") And ((STAFF.POSITION) = '"
& STAFF & "')) " & _
"ORDER BY AUDIT.ADATE, AUDIT.STAFFID, AUDIT.TIME;"
End Select
'Open source table
rss.Open SQL, Conn, adOpenKeyset, adLockOptimistic
When I use the first SQL statement, the recordset opens fine. When I use
the second (which is very similar, but has a join) I get the following
run-time error: Method 'Open' of object "-Recordset' failed. I can not
figure out what the problem is. Do I need to use different arguments for the
Open method?
Thanks in advance.
DEI