Testing for NewRecord on subform

M

Matt P

I have a main form with two subforms nested. I am trying to test for
a newrecord on the 2nd subform from the main form.

Me.SetFocus
Me!subCompanyAddresses1.SetFocus
Me!subCompanyAddresses1.Form!subAdjusters2.SetFocus
If Me!subCompanyAddresses1.Form!subAdjusters2.Form.NewRecord =
True Then
Stop
End If

I go to add a new record and then I click the button which has this
underlying vb code and it doesn't register the new record. On the
subform itself the test works. Anyone have any suggestions?
 
M

Matt P

I have a main form with two subforms nested.  I am trying to test for
a newrecord on the 2nd subform from the main form.

        Me.SetFocus
        Me!subCompanyAddresses1.SetFocus
        Me!subCompanyAddresses1.Form!subAdjusters2.SetFocus
        If Me!subCompanyAddresses1.Form!subAdjusters2.Form.NewRecord =
True Then
        Stop
        End If

I go to add a new record and then I click the button which has this
underlying vb code and it doesn't register the new record.  On the
subform itself the test works.  Anyone have any suggestions?

Well, I got around it by adding an unbound text box to the form and
then on the OnCurrent event of the subform the textbox changes to 1 if
it is a new record. My new code checks to see if the value of the
textbox is 1:

Me.SetFocus
Me!subCompanyAddresses1.SetFocus
Me!subCompanyAddresses1.Form!subAdjusters2.SetFocus
If Me!subCompanyAddresses1.Form!subAdjusters2.Form!
txtTestIfNewRecord.Value = 1 Then
Stop
End If

If anyone would still care to enlighten me on how I could have done
this another way it would be greatly appreciated, but if not this way
works as well.

Thanks,
Matt P
 

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