I have code that was working till I added one more line to it. The new line is to get access to another record. I have tried many things with no success. For the conditions from the query fyord =11. I code that has error is in blue. I was hoping to get some assistance.
Tom
Tom
Code:
Public Function CurMonYr(strUCI As String, strMon As String, strYr As String, iMon As Integer)
Dim strSql As String
Dim rstYr As DAO.Recordset
Dim db As DAO.Database
Dim intYr As Integer
Set db = CurrentDb
strSql = "SELECT fy.uci,fy.rptpddiff,fy.mon_shnm,fy.cy " & _
"FROM dbo_rpt_FYInfo fy " & _
"WHERE fy.uci='" & strUCI & "' " & _
"AND fy.rptpddiff=1;"
Set rstYr = db.OpenRecordset(strSql, dbOpenSnapshot)
If Not rstYr.EOF Then ' Make sure not empty set
With rstYr
.MoveLast
.MoveFirst
End With
For intYr = 0 To rstYr.RecordCount
' Set Variables
strUCI = (rstYr![uci])
strMon = (rstYr![mon_shnm])
strYr = (rstYr![cy])
[Blue] iMon = (rstYr![fyord]) [/Blue]
Next intYr
End If
End Function