Editing subform data from VB

B

bhNish

Hi & Happy New Year!

I have a form containing a subform in which I want to automatically
copy information from the form to the subform. Within the event
procedure for a button click, the code works ok for the first record
that it modifies, but the next record returns the error
"No Current Record" (runtime error 3021)
when I try to enable Edit mode.

I've narrowed it down to the fact that when I open the form, after
the first successful Edit...Update, the next record that I try to
Edit, I get the error.

I'm stumped... can anybody help me?

' do for each record
Me.Recordset.MoveFirst
For i = 1 To Me.Recordset.RecordCount

' copy data from form1 to form2
rtnFlag = CompareFormFields(Me, Me.SubFormMemberTo.Form, True)

' goto next record
Me.Recordset.MoveNext

Next i
' enddo - for each record


Function CompareFormFields(form1 As Form, form2 As Form, copyFlag As Boolean) As Boolean

' if not all fields of form2 same as form1 then

... <blah> ...
ctrlSource= "someFieldName"
... <blah> ...

form2.Recordset.Edit
form2.Recordset.Fields(ctrlSource) = form1.Recordset.Fields(ctrlSource)
form2.Recordset.Update

' end if

... <blah> ...

End Function
 

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