Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 5th, 2005, 10:59 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old October 5th, 2005, 05:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.