M
MHiemstra
I have the following code to being back values to a form...If I use DAO all
works well however, I am trying to learn ADO and running into a SNAFU. ADO
works in one example but in another I don't understand the error message and
why is it failing.
Here is the code that works in DAO...
Public Function intCurrent() As Integer
Dim rs As DAO.Recordset
Dim strSQL As String
If Nz(Forms!SHD_REGRESSION_TESTINGS.Regression_ID.Value, 0) <> 0 Then
strSQL = /BIG OLE QUERY/ * didn't want to post the whole thing
Set rs = CurrentDb.OpenRecordset(strSQL)
intCurrent = rs(0)
Else
intCurrent = 0
End If
Set rs = Nothing
End Function
The following produces this error: Method 'Open' of Object '_Recordset'
failed. What I don't get is I have the exact same ADO funtion elsewhere in
another function and it works fine.
Public Function intCurrent() As Integer
Dim rs As New Recordset
Dim strSQL As String
If Nz(Forms!SHD_REGRESSION_TESTINGS.Regression_ID.Value, 0) <> 0 Then
strSQL = BIG OLE QUERY
rs.Open strSQL, CurrentProject.Connection
intCurrent = rs(0)
Else
intCurrent = 0
End If
rs.Close
Please help....
works well however, I am trying to learn ADO and running into a SNAFU. ADO
works in one example but in another I don't understand the error message and
why is it failing.
Here is the code that works in DAO...
Public Function intCurrent() As Integer
Dim rs As DAO.Recordset
Dim strSQL As String
If Nz(Forms!SHD_REGRESSION_TESTINGS.Regression_ID.Value, 0) <> 0 Then
strSQL = /BIG OLE QUERY/ * didn't want to post the whole thing
Set rs = CurrentDb.OpenRecordset(strSQL)
intCurrent = rs(0)
Else
intCurrent = 0
End If
Set rs = Nothing
End Function
The following produces this error: Method 'Open' of Object '_Recordset'
failed. What I don't get is I have the exact same ADO funtion elsewhere in
another function and it works fine.
Public Function intCurrent() As Integer
Dim rs As New Recordset
Dim strSQL As String
If Nz(Forms!SHD_REGRESSION_TESTINGS.Regression_ID.Value, 0) <> 0 Then
strSQL = BIG OLE QUERY
rs.Open strSQL, CurrentProject.Connection
intCurrent = rs(0)
Else
intCurrent = 0
End If
rs.Close
Please help....