SubForm Recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

I have the following codes in my command button in a Main Form. When
cmdbutton is click, nothing happens. It works when the subform is navigated
first before clicking the cmdbutton. I tried to insert a "setfocus" command
before the "rst.MoveFirst", it works but on the second click. Any idea.
Thansk

Private Sub cmdSendEmail_Click()
Dim rst As DAO.Recordset
Dim frm As Form
Dim i As Integer


Set rst = Me![frmAssignment].Form.Recordset
Set frm = Form_frmAssignment
MyNum = rst.RecordCount

rst.MoveFirst
Do While MyNum <> frm.CurrentRecord
For i = 1 To MyNum
MsgBox "Sending E-mail"
rst.MoveNext
Next
Loop
End Sub
 
By using the form's Recordset, you are actually navigating through the
records in the form. If you use RecordsetClone instead it will solve the
problem. Also, I'm not sure how Form_frmAssignment is working :-/

Try this instead:
Set frm = Me![frmAssignment].Form
Set rst = frm.RecordsetClone
 
Back
Top