H
Helge
Hi
Developing in Access 2002:
I have a function that reads from an SQLServer an creates a DAO.Recordset.
When I create the recordset inside the function it is valid and OK. But when
I try to return the user-defined type (that keeps the recordset) to the
caller, the recordset is invalid.
Why?
The code:
In some module:
Type RS_CIC ' Create user-defined type.
l_RS As DAO.Recordset
End Type
.....................
Public Function get_select_RS(as_select_SQL As String) As RS_CIC
Dim rstTemp As DAO.Recordset
<some code>
Set rstTemp = gc_con_CIC.OpenRecordset(as_select_SQL, dbOpenDynamic)
Set my_RS_CIC.l_RS = rstTemp
get_select_RS = my_RS_CIC
<<Here is the recordet OK>>
End Function
.....................
The Caller:
Dim l_RS As DAO.Recordset
Dim my_new_RS_CIC As RS_CIC
my_new_RS_CIC = get_select_RS("SELECT col1, col2 FROM table1;")
Set l_RS = my_new_RS_CIC.l_RS
<<Here the recordset (l_RA) is invalid>>
regards,
Helge
Developing in Access 2002:
I have a function that reads from an SQLServer an creates a DAO.Recordset.
When I create the recordset inside the function it is valid and OK. But when
I try to return the user-defined type (that keeps the recordset) to the
caller, the recordset is invalid.
Why?
The code:
In some module:
Type RS_CIC ' Create user-defined type.
l_RS As DAO.Recordset
End Type
.....................
Public Function get_select_RS(as_select_SQL As String) As RS_CIC
Dim rstTemp As DAO.Recordset
<some code>
Set rstTemp = gc_con_CIC.OpenRecordset(as_select_SQL, dbOpenDynamic)
Set my_RS_CIC.l_RS = rstTemp
get_select_RS = my_RS_CIC
<<Here is the recordet OK>>
End Function
.....................
The Caller:
Dim l_RS As DAO.Recordset
Dim my_new_RS_CIC As RS_CIC
my_new_RS_CIC = get_select_RS("SELECT col1, col2 FROM table1;")
Set l_RS = my_new_RS_CIC.l_RS
<<Here the recordset (l_RA) is invalid>>
regards,
Helge