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.
|