R
Rafi
I have the following code composed of two functions which results in the
above error. Note that if I run the second query independently I do not
encounter any problems. Your help is much appreciated.
Function IDD_Growth()
Dim stSQL As String
Dim stSQL2 As String
Dim stAE As String
Dim db As Database
Dim rs As Recordset
Dim CurrQtr As Double
Dim PrevQtr As Double
Dim Yr As Long
' Set values for Current Yr
Yr = 2006
Q = 1
stSQL = " Select Distinct AENAME" _
& " From QRY_VALID_ACCT_LIST"
MsgBox stSQL
Set db = CurrentDb()
Set rst = db.OpenRecordset(stSQL)
With rst
If Not (.EOF And .BOF) Then
Do Until .EOF
stAE = rst.Fields("AENAME")
MsgBox stAE
Call CurrYr(stAE, Q, Yr)
rst.MoveNext
Loop
End If
..Close
End With
Set rst = Nothing
Set db = Nothing
End Function
Function CurrYr(stAE, Q, Yr)
MsgBox (stAE & "/" & Q & "/" & Yr)
Dim stSQL2 As String
stSQL = "Select Comp_Rev" _
& " From Qry_IDD_Growth_By_AE" _
& " Where (((Qry_IDD_Growth_By_AE.AENAME) = """ & stAE & """)" _
& " and ((Qry_IDD_Growth_By_AE.Qtr) = " & Q & ")" _
& " and ((Qry_IDD_Growth_By_AE.Yr) = " & Yr & "));"
MsgBox stSQL
Set rst = db.OpenRecordset(stSQL)
With rst2
If Not (.EOF And .BOF) Then
Do Until .EOF
CurrQtr = rst2.Fields("Comp_Rev")
MsgBox CurrQtr
rst2.MoveNext
Loop
End If
End With
End Function
above error. Note that if I run the second query independently I do not
encounter any problems. Your help is much appreciated.
Function IDD_Growth()
Dim stSQL As String
Dim stSQL2 As String
Dim stAE As String
Dim db As Database
Dim rs As Recordset
Dim CurrQtr As Double
Dim PrevQtr As Double
Dim Yr As Long
' Set values for Current Yr
Yr = 2006
Q = 1
stSQL = " Select Distinct AENAME" _
& " From QRY_VALID_ACCT_LIST"
MsgBox stSQL
Set db = CurrentDb()
Set rst = db.OpenRecordset(stSQL)
With rst
If Not (.EOF And .BOF) Then
Do Until .EOF
stAE = rst.Fields("AENAME")
MsgBox stAE
Call CurrYr(stAE, Q, Yr)
rst.MoveNext
Loop
End If
..Close
End With
Set rst = Nothing
Set db = Nothing
End Function
Function CurrYr(stAE, Q, Yr)
MsgBox (stAE & "/" & Q & "/" & Yr)
Dim stSQL2 As String
stSQL = "Select Comp_Rev" _
& " From Qry_IDD_Growth_By_AE" _
& " Where (((Qry_IDD_Growth_By_AE.AENAME) = """ & stAE & """)" _
& " and ((Qry_IDD_Growth_By_AE.Qtr) = " & Q & ")" _
& " and ((Qry_IDD_Growth_By_AE.Yr) = " & Yr & "));"
MsgBox stSQL
Set rst = db.OpenRecordset(stSQL)
With rst2
If Not (.EOF And .BOF) Then
Do Until .EOF
CurrQtr = rst2.Fields("Comp_Rev")
MsgBox CurrQtr
rst2.MoveNext
Loop
End If
End With
End Function