Subform updating

G

Guest

I have a form called NewDataEntry which contains a subform called
ActivityNewPart. I would like to click a command button on the main form
which would then cause a field called Plan on the subform to have the value
0. The following is the code that I am using but I am receiving a 'Method or
Data Member not found' error.
Private Sub Command46_Click()
Forms!NewDataEntry!SubformControl.Form.ActivityNewPart.SetFocus
Me.ActivityNewPart.Plan.Value = 0
End Sub

Thanks for any help.
JoeP
 
K

Ken Snell \(MVP\)

No need to set focus to that control:

Private Sub Command46_Click()
Forms!NewDataEntry!SubformControl!ActivityNewPart.Value = 0
End Sub
 
G

Guest

Hi Jo

Set Value of Plan to 0

Private Sub ButtonName_Click()
Forms!NewDataEntry!ActivityNewPart.Form!Plan = 0
End Sub


Set focus to Plan then set value to 0

Private Sub ButtonName_Click()
Me.ActivityNewPart.SetFocus
Forms!NewDataEntry!ActivityNewPart.Form!Plan.SetFocus
Forms!NewDataEntry!ActivityNewPart.Form!Plan = 0
End Sub


Change ButtonName to what it is

Good luck
 
L

Larry Linson

JoeP said:
I have a form called NewDataEntry which contains a
subform called ActivityNewPart. I would like to click
a command button on the main form which would then
cause a field called Plan on the subform to have
the value 0.

Ken and Wayne -- as the Command Button is on the main form, why would it be
needful to use the "Forms!Formname" address?

Wouldn't it be simpler, and equally effective, to use the following?

Me!ActivityNewPart.Form!Plan = 0

I'd also comment that, if the Form in the Subform Control is in continuous
forms view, the currently-selected Record's Path Control will be set to 0.

Larry Linson
Microsoft Access MVP
 
K

Ken Snell \(MVP\)

Larry Linson said:
Ken and Wayne -- as the Command Button is on the main form, why would it
be needful to use the "Forms!Formname" address?

Wouldn't it be simpler, and equally effective, to use the following?

Me!ActivityNewPart.Form!Plan = 0

Yes; I was just using the poster's syntax.
 

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