By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,784 Members | 3,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,784 IT Pros & Developers. It's quick & easy.

DAO.recordset

P: n/a
Hello,

I'm trying to debug an access project in which two kind of recordset
are used: ADODB.recordset and DAO.recordset. I'm trying to set the
whole project on DAO.recordset, but the following function does not
work:

Public Function GetRecordset(pstrCmdTxt As String, Optional
pintCursorType As CursorTypeEnum = adOpenStatic) As Recordset ' was
ADODB.recordset

On Error GoTo GetRecordset_Err

Dim dsRecset As DAO.Recordset ' was ADODB

Set GetRecordset = Nothing
If Not CurrentProject.IsConnected Then
End If

'Set dsRecset = New DAO.Recordset ' was ADODB

'With dsRecset
' .CursorLocation = adUseClient
' .CursorType = adOpenStatic
'End With

Set GetRecordset = CurrentDb.OpenRecordset(pstrCmdTxt)
'CurrentProject.AccessConnection.Execute (pstrCmdTxt)
Exit Function

GetRecordset_Err:
Beep
MsgBox Err.Description, vbCritical, Application.Name
MsgBox pstrCmdTxt, vbOKOnly

End Function

Originally the problem was that I Was trying to do the following :
Set mdsMain = sbfMain.Form.RecordsetClone
Where mdsMain is a DAO.recordset (RecordsetClone seems to return a
ADODB.recordset)

If someone could help on this, I would be very gratefull.

Marmotte_dodue

Jun 12 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

ma***********@gmail.com wrote:
Hello,

I'm trying to debug an access project in which two kind of recordset
are used: ADODB.recordset and DAO.recordset. I'm trying to set the
whole project on DAO.recordset, but the following function does not
work:

Public Function GetRecordset(pstrCmdTxt As String, Optional
pintCursorType As CursorTypeEnum = adOpenStatic) As Recordset ' was
ADODB.recordset

On Error GoTo GetRecordset_Err

Dim dsRecset As DAO.Recordset ' was ADODB

Set GetRecordset = Nothing
If Not CurrentProject.IsConnected Then
End If

'Set dsRecset = New DAO.Recordset ' was ADODB

'With dsRecset
' .CursorLocation = adUseClient
' .CursorType = adOpenStatic
'End With

Set GetRecordset = CurrentDb.OpenRecordset(pstrCmdTxt)
'CurrentProject.AccessConnection.Execute (pstrCmdTxt)
Exit Function

GetRecordset_Err:
Beep
MsgBox Err.Description, vbCritical, Application.Name
MsgBox pstrCmdTxt, vbOKOnly

End Function

Originally the problem was that I Was trying to do the following :
Set mdsMain = sbfMain.Form.RecordsetClone
Where mdsMain is a DAO.recordset (RecordsetClone seems to return a
ADODB.recordset)

If someone could help on this, I would be very gratefull.

Marmotte_dodue


I suggest that you post the original code which you are trying to
debug, with the full description of the error that occurs, (Use <Ctrl
C> while the message box is visible and <Ctrl V> to paste the message
into your post), and the line where the error occurs.

Depending on the Version of Access/Jet, DAO recordsets may cause
problems when they are not closed explicitly. Initializing a function
as a DAO recordset could make this difficult.

This is doable but I wouldn't:

Public Function GetRecordset( _
ByVal Source As String, _
Optional ByVal RecordSetType As DAO.RecordsetTypeEnum = dbOpenDynamic)
Set GetRecordset = CurrentDb.OpenRecordset(Source, RecordSetType)
End Function

A more common procedure is:
Public Sub IRecommend()
Dim r As DAO.Recordset
Set r = CurrentDb.OpenRecordset("SELECT * FROM Table1",
dbOpenDynamic)
'do some stuff with r
Set r = Nothing
End Sub

Jun 12 '06 #2

P: n/a
"ma***********@gmail.com" <ma***********@gmail.com> wrote in
news:11**********************@i40g2000cwc.googlegr oups.com:
Originally the problem was that I Was trying to do the following :
Set mdsMain = sbfMain.Form.RecordsetClone
Where mdsMain is a DAO.recordset (RecordsetClone seems to return a
ADODB.recordset)


You don't way what in your function doesn't work. I suspect that the
lack of a qualified type declaration is the problem, though. You
declare it as "As Recordset" instaed of "As DAO.Recordset" which
means that which type depends entirely on the order of the
references -- it ADO is first, it will return ADO, if DAO is first,
it will return DAO.

As to recordsetclones, I thought all form-based recordsets were DAO.

In any event, when working with a recordsetclone, I never declare a
recordset variable at all, I just do this:

With sbfMain.Form.RecordsetClone
[work with the recordset here]
End With

It's much cleaner to do it this way, seems to me, and avoids any
question of recordset variable types.

And, of course, you haven't identified what you're trying to do in
the first place. Many people reach for recordsets when they ought to
be using SQL.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 12 '06 #3

P: n/a
rkc
David W. Fenton wrote:
As to recordsetclones, I thought all form-based recordsets were DAO.

The only RecordsetClone I can find in Access, DAO or ADODB is a
property of Access.Form and it is always a DAO.Recordset. The object
browser does not say so. It says it's an Object, but it has properties
that only a DAO Recordset has whether there is a reference to DAO or not.

Jun 12 '06 #4

P: n/a
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:fS*******************@twister.nyroc.rr.com:
David W. Fenton wrote:
As to recordsetclones, I thought all form-based recordsets were
DAO.


The only RecordsetClone I can find in Access, DAO or ADODB is a
property of Access.Form and it is always a DAO.Recordset. The
object browser does not say so. It says it's an Object, but it has
properties that only a DAO Recordset has whether there is a
reference to DAO or not.


Thanks for that -- I rather confused things by referring to the
form's recordset instead of the recordsetclone (I still do most of
my programming in A97, where there is no form recordset object
accessible to the programmer).

Can you assign an ADO recordset to a form?

If so, is the RecordsetClone of an ADO recordset a DAO recordset?
That would be very weird, if it were.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 12 '06 #5

P: n/a
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:fS*******************@twister.nyroc.rr.com:

David W. Fenton wrote:

As to recordsetclones, I thought all form-based recordsets were
DAO.


The only RecordsetClone I can find in Access, DAO or ADODB is a
property of Access.Form and it is always a DAO.Recordset. The
object browser does not say so. It says it's an Object, but it has
properties that only a DAO Recordset has whether there is a
reference to DAO or not.

Thanks for that -- I rather confused things by referring to the
form's recordset instead of the recordsetclone (I still do most of
my programming in A97, where there is no form recordset object
accessible to the programmer).

Can you assign an ADO recordset to a form?

If so, is the RecordsetClone of an ADO recordset a DAO recordset?
That would be very weird, if it were.


You can bind a form to an ADODB.Recordset and that's a damn
good question.

When directly bound to an ADODB.Recordset the Form.RecordsetClone
is not a DAO.Recordset. Properties distinct to a DAO.Recordset are
not available. Properties distinct to an ADODB.Recordset are.


Jun 12 '06 #6

P: n/a
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uw*******************@twister.nyroc.rr.com:
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:fS*******************@twister.nyroc.rr.com:
David W. Fenton wrote:

As to recordsetclones, I thought all form-based recordsets were
DAO.

The only RecordsetClone I can find in Access, DAO or ADODB is a
property of Access.Form and it is always a DAO.Recordset. The
object browser does not say so. It says it's an Object, but it
has properties that only a DAO Recordset has whether there is a
reference to DAO or not.


Thanks for that -- I rather confused things by referring to the
form's recordset instead of the recordsetclone (I still do most
of my programming in A97, where there is no form recordset object
accessible to the programmer).

Can you assign an ADO recordset to a form?

If so, is the RecordsetClone of an ADO recordset a DAO recordset?
That would be very weird, if it were.


You can bind a form to an ADODB.Recordset and that's a damn
good question.

When directly bound to an ADODB.Recordset the Form.RecordsetClone
is not a DAO.Recordset. Properties distinct to a DAO.Recordset are
not available. Properties distinct to an ADODB.Recordset are.


In other words, record navigation would have to be done completely
differently, since .FindFirst is DAO only.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 13 '06 #7

P: n/a
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uw*******************@twister.nyroc.rr.com:

David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:fS*******************@twister.nyroc.rr.com :
David W. Fenton wrote:
>As to recordsetclones, I thought all form-based recordsets were
>DAO.

The only RecordsetClone I can find in Access, DAO or ADODB is a
property of Access.Form and it is always a DAO.Recordset. The
object browser does not say so. It says it's an Object, but it
has properties that only a DAO Recordset has whether there is a
reference to DAO or not.

Thanks for that -- I rather confused things by referring to the
form's recordset instead of the recordsetclone (I still do most
of my programming in A97, where there is no form recordset object
accessible to the programmer).

Can you assign an ADO recordset to a form?

If so, is the RecordsetClone of an ADO recordset a DAO recordset?
That would be very weird, if it were.


You can bind a form to an ADODB.Recordset and that's a damn
good question.

When directly bound to an ADODB.Recordset the Form.RecordsetClone
is not a DAO.Recordset. Properties distinct to a DAO.Recordset are
not available. Properties distinct to an ADODB.Recordset are.

In other words, record navigation would have to be done completely
differently, since .FindFirst is DAO only.


You can use ADODB.Recordset.Find to navigate a record in much the
same way you can use FindFirst. The syntax is a bit different.
The bookmark property works with the Form.Bookmark.
Jun 13 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.