Hello, when I type this query into the query editor, it works fine, but when I use VBA to run this query, it gives me no results.
Query:
Code:
SELECT COUNTY.PK_COUNTY, COUNTY.COUNTY_NAME FROM DESIGN_EXCEPTION INNER JOIN (COUNTY INNER JOIN EXCEPTION_COUNTY_CONNECTOR ON COUNTY.PK_COUNTY = EXCEPTION_COUNTY_CONNECTOR.FK_COUNTY) ON DESIGN_EXCEPTION.PK_DESIGN_EXCEPTION = EXCEPTION_COUNTY_CONNECTOR.FK_DESIGN_EXCEPTION WHERE EXCEPTION_COUNTY_CONNECTOR.FK_DESIGN_EXCEPTION= 149 AND DESIGN_EXCEPTION.PRIMARY_DISTRICT=10 AND COUNTY.FK_DISTRICT = 10;
Function i use to run the query
Code:
Public Function GetRecords(ByVal strSQL As String, ByRef rstRecordSet As ADODB.Recordset, Optional ByRef actionSQL As Variant = "") As Boolean
If (actionSQL <> "") Then
Dim cmdCommand As New ADODB.Command
End If
Dim rstCommand As New ADODB.Command
If (actionSQL <> "") Then
MainConnection.Execute actionSQL, dbFailOnError
With cmdCommand
.ActiveConnection = MainConnection
.CommandText = actionSQL
.CommandType = adCmdText
End With
End If
'Defines our command object
With rstCommand
.ActiveConnection = MainConnection
.CommandText = strSQL
.CommandType = adCmdText
End With
With rstRecordSet
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open rstCommand
End With
If (actionSQL <> "") Then
Set cmdCommand = Nothing
End If
Set rstCommand = Nothing
End Function
ÃaÃeVi£