Open suform with the dataentry setting to yes.

J

JimN

A combo box in the form selects a record and it is required that a sub-form
has a DataEntry setting of yes when the combo box selection is changed. The
existing code for the combo box OnChange event includes:
Forms![FormName].Form![SubFormName].DataEntry=Yes. When a selection is made
in the combobox, an error message says "Object does not support this property
or method". When DeBug is clicked, the above code is highlighted in the VB
editor. Question is what is wrong?
 
B

Brian Coiley

JimN said:
A combo box in the form selects a record and it is required that a sub-form
has a DataEntry setting of yes when the combo box selection is changed. The
existing code for the combo box OnChange event includes:
Forms![FormName].Form![SubFormName].DataEntry=Yes. When a selection is made
in the combobox, an error message says "Object does not support this property
or method". When DeBug is clicked, the above code is highlighted in the VB
editor. Question is what is wrong?

[SubFormName] refers to the subform control on the main form, not to the
form contained within the subform control. Try [SubFormName].Form.
 
D

Dirk Goldgar

JimN said:
A combo box in the form selects a record and it is required that a
sub-form has a DataEntry setting of yes when the combo box selection
is changed. The existing code for the combo box OnChange event
includes: Forms![FormName].Form![SubFormName].DataEntry=Yes. When a
selection is made in the combobox, an error message says "Object does
not support this property or method". When DeBug is clicked, the
above code is highlighted in the VB editor. Question is what is wrong?

Try this:

Me![SubFormName].Form.DataEntry = True

where "SubFormName" is the name of the subform *control* on the main
form -- that is, the control that provides the window within which you
view the subform. This may or may not be the same as the name of the
form object being displayed in that window.

I also recommend using the combo box's AfterUpdate event for this,
rather than the Change event. If the user types in the combo box rather
than using the mouse, the Change event will fire for each character
typed.
 
J

JimN

Tried Me![SubFormName].Form.DataEntry = True and
Me![SubFormName].Form.DataEntry = Yes. The Subform does not clear and
previous records are still showing in subform.

Dirk Goldgar said:
JimN said:
A combo box in the form selects a record and it is required that a
sub-form has a DataEntry setting of yes when the combo box selection
is changed. The existing code for the combo box OnChange event
includes: Forms![FormName].Form![SubFormName].DataEntry=Yes. When a
selection is made in the combobox, an error message says "Object does
not support this property or method". When DeBug is clicked, the
above code is highlighted in the VB editor. Question is what is wrong?

Try this:

Me![SubFormName].Form.DataEntry = True

where "SubFormName" is the name of the subform *control* on the main
form -- that is, the control that provides the window within which you
view the subform. This may or may not be the same as the name of the
form object being displayed in that window.

I also recommend using the combo box's AfterUpdate event for this,
rather than the Change event. If the user types in the combo box rather
than using the mouse, the Change event will fire for each character
typed.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
J

JimN

Put in Form![FormName]![SubFormName].Form.DataEntry = Yes and subform does
not clear and previous records are still showing.


Brian Coiley said:
JimN said:
A combo box in the form selects a record and it is required that a sub-form
has a DataEntry setting of yes when the combo box selection is changed. The
existing code for the combo box OnChange event includes:
Forms![FormName].Form![SubFormName].DataEntry=Yes. When a selection is made
in the combobox, an error message says "Object does not support this property
or method". When DeBug is clicked, the above code is highlighted in the VB
editor. Question is what is wrong?

[SubFormName] refers to the subform control on the main form, not to the
form contained within the subform control. Try [SubFormName].Form.
 
D

Dirk Goldgar

JimN said:
Tried Me![SubFormName].Form.DataEntry = True and
Me![SubFormName].Form.DataEntry = Yes. The Subform does not clear and
previous records are still showing in subform.

The equivalent code certainly works for me in a test form and subform,
so I suspect one of two things is going on. Possibly (a) that line of
code is never being executed -- so you should set a breakpoint and step
through the code to make sure -- or (b) you've got the wrong name for
"SubFormName" -- it must be the name of the subform control on the main
form, which may or may not be the same as the name of the form object
that the control is displaying.

Please check these possibilities and get back to us.
 

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