error when referring to a control in a subform

associates

Registered User.
Local time
Today, 05:52
Joined
Jan 5, 2006
Messages
94
Hi,

I was wondering if I could get some help with Access form.

What I was trying to do is to disable a control on a subform but with no success. So the VBA code I use is

[Forms]![BookOrder]![myBook Order Details].Form!status.Enabled = False

where: "myBook Order Details" as a subform resides on the main form "BookOrder".

When I run this, I got an error with the message "Microsoft Access can't find the field 'myBook Order Details' referred to in your expression". I wonder what I have missed out.

Any help would be greatly appreciated. BTW, I use microsoft access 2010.

Thank you
 
Where do you want to refer from.

Are you on the Main Form or Sub Form or are you somewhere else.
 
Thank you for your reply.

Sorry that I forgot to mention that I am on a different form somewhere else but trying to get into a subform within another form. I wonder if this is possible.

Thank you
 
The subform control (which is the container housing your actual subform) on the parent form apparently is not reachable through myBook Order Details

I guess this is another case of spaces in control/field/table/form names - always trouble. Don't use spaces in naming objects.

The cure: copy your subform. Rename it to the same as before but without spaces. Delete the subform control from parent form. Drag your fresh subform onto the parent form.

On reflection: The subform control may have a different name from the subform it houses. You can always do this:


  1. Add a text box to your form
  2. Open the textbox's properties
  3. In Control Source , click the ... that opens the Expression Builder
  4. Navigate to the control on another open form whose value you want
  5. Click Paste
  6. Click OK

Now you have the reference you can copy (and remember to delete the now useless textbox)
 
Last edited:
I fear a spelling mistake.

Does the Control, which is the SubForm, and can be viewed in the properites, have the same name as the Sub Form.
 

Users who are viewing this thread

Back
Top Bottom