Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2005, 10:59 AM
Registered User
 
Join Date: Sep 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DAO Recordset Problems

I'm trying to retrieve a value from a query using DAO in a function. During the testing when I run the procedure I get the following error:

Run-time error '3102': Circular reference caused by qryEmpRatesWithFringes.

Here's a copy of the procedure:

Public Function Test(strEmployeeNum As String, dtmDate As Date) As Single

    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim rec As DAO.Recordset
    Dim strSQL As String
    Dim intYear As Integer
    Dim sngRate As Single

    intYear = Year(dtmDate)
    strSQL = "SELECT curHRateWithFringes FROM qryEmpRatesWithFringes " & _
               "WHERE strEmpNum = " & strEmployeeNum & _
               " AND intFiscalPayYr = " & intYear
    Set db = CurrentDb()
    Set qdf = db.CreateQueryDef("")

    With qdf
        .SQL = strSQL
        Set rec = .OpenRecordset(dbOpenDynaset)
        rec.MoveFirst
    End With

    With rec
        Do While Not .EOF
            sngRate = !curHRateWithFringes
            .MoveNext
        Loop
    End With
    Test = sngRate
    rec.Close
End Function

When I click the debug button, it highlights the line of code that
reads:

Set rec = .OpenRecordset(dbOpenDynaset)

Any help would greatly be appreciated.

Signed,

Frustrated and Abused.
 
Old October 5th, 2005, 05:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It seems like the circular reference is in qryEmpRatesWithFringes, not particularly in your recordset code.
Try running qryEmpRatesWithFringes just by itself, without any code at all - does the problem happen there too?

I am a loud man with a very large hat. This means I am in charge





Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Working with DAO recordset cesemj VB How-To 6 June 9th, 2006 11:07 PM
recordset problems p2ptolu Classic ASP Databases 0 July 9th, 2005 07:54 AM
Convert ADO reocordset to DAO recordset use report redd Access 1 September 24th, 2004 03:34 PM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.