Here's a problem I've spent almost a week trying to crack, and I'll raise the flag here. I have three recordsets to loop through. One of the recordsets, rst1, may have only one record in it but it needs to change the fields each time it loops through the code, if there are records.
The rst1 table looks like this:
ElementarySchool SumOf2004_Total SumOf2005_total......
School A 100 220
This code does the first loop great, but I can't figure out how to write it so it will come back to this rst1 recordset and change fields. That's my problem. Can anybody help??
-----------
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim rst3 As DAO.Recordset
Set dbs = DBEngine.OpenDatabase("C:\My Documents\School District Project\BSSD_Student_Estimation.mdb")
Set rst1 = dbs.OpenRecordset("tblTotal_Schools_New_Construction", dbOpenDynaset)
Set rst2 = dbs.OpenRecordset("tblGrade", dbOpenDynaset)
Set rst3 = dbs.OpenRecordset(comboElemen & "_Enrollment_New ", dbOpenDynaset)
If rst1.EOF = True And rst1.BOF = True Then
Call MsgBox("There are no records")
Else
rst1.MoveFirst
rst2.MoveFirst
rst3.MoveFirst
Do
Do Until rst1.EOF = True
If rst1.Fields("ElementarySchool") = comboElemen And rst2.Fields("Grade") = "Kindergarten" Then
rst3.Edit
rst3.Fields("2004_New_Construction") = [rst1.Fields("Sumof2004_Total") * rst2.Fields("New_Construction_Calculation")]
rst3.Update
rst1.MoveNext
Exit Do
End If
Loop
The rst1 table looks like this:
ElementarySchool SumOf2004_Total SumOf2005_total......
School A 100 220
This code does the first loop great, but I can't figure out how to write it so it will come back to this rst1 recordset and change fields. That's my problem. Can anybody help??
-----------
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim rst3 As DAO.Recordset
Set dbs = DBEngine.OpenDatabase("C:\My Documents\School District Project\BSSD_Student_Estimation.mdb")
Set rst1 = dbs.OpenRecordset("tblTotal_Schools_New_Construction", dbOpenDynaset)
Set rst2 = dbs.OpenRecordset("tblGrade", dbOpenDynaset)
Set rst3 = dbs.OpenRecordset(comboElemen & "_Enrollment_New ", dbOpenDynaset)
If rst1.EOF = True And rst1.BOF = True Then
Call MsgBox("There are no records")
Else
rst1.MoveFirst
rst2.MoveFirst
rst3.MoveFirst
Do
Do Until rst1.EOF = True
If rst1.Fields("ElementarySchool") = comboElemen And rst2.Fields("Grade") = "Kindergarten" Then
rst3.Edit
rst3.Fields("2004_New_Construction") = [rst1.Fields("Sumof2004_Total") * rst2.Fields("New_Construction_Calculation")]
rst3.Update
rst1.MoveNext
Exit Do
End If
Loop