SubForm Recordset

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
 
G

Graham Mandeno

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top