Why is this not a valid construct from within a form? Specifically, when I put in the msgbox the whole operation just simply fails (no msgbox, no breakpoint). It works fine when I take out the Msgbox
Dim db As Database
Dim QD As QueryDef
Dim RS As Recordset
Set db = CurrentDb
'
Set QD = db.QueryDefs("A")
Set RS = QD.OpenRecordset
Do While Not RS.EOF
MsgBox "test=" & RS![SumOfChargeNetOut]
Me!txtExample = RS![SumOfChargeNetOut]
Me![txtChargesInCurrMo] = RS![SumOfChargeNetIn]
RS.MoveNext
Loop
RS.Close
db.Close
Set db = Nothing
Dim db As Database
Dim QD As QueryDef
Dim RS As Recordset
Set db = CurrentDb
'
Set QD = db.QueryDefs("A")
Set RS = QD.OpenRecordset
Do While Not RS.EOF
MsgBox "test=" & RS![SumOfChargeNetOut]
Me!txtExample = RS![SumOfChargeNetOut]
Me![txtChargesInCurrMo] = RS![SumOfChargeNetIn]
RS.MoveNext
Loop
RS.Close
db.Close
Set db = Nothing