Form.Requery Syntax

whdyck

Registered User.
Local time
Today, 09:28
Joined
Aug 8, 2011
Messages
169
I'm using MS Access 2003.

I'm puzzled about some behaviour that I cannot explain. Was hoping someone might be able to illuminate me.

I have a form on which I have a combo box, call it cbo1. In its AfterUpdate() event handler, I have the following code:
Code:
Me.fsubUntPurNewBaseUnitOptions.Form.Requery

Note that fsubUntPurNewBaseUnitOptions is the name of the subform control, whose SourceObject is fsubUntPurBaseUnitOptions
If I view the form in Datasheet view, changing the value in the combobox results in the following error message 2455:
You entered an expression that has an invalid reference the the property Form/Report.
However, if I view the form in Form View, changing the combobox value generates no error.

So two questions:
1. It's my understanding that I should be using subformcontrolname.Requery. So why does Access intellisense offer me
fsubUntPurNewBaseUnitOptions.Form.Requery?
2. Why should the error message appear in Datasheet View, but not in Form View?

Thanks for any help you can give.

Wayne
 
If I view the form in Datasheet view

which form are you referring to - the master form or the sub form?

A form in datasheet view cannot access a subform which is otherwise available in single or continuous form view
 
To get the full reference to an object, particularly with sub forms, I always have the main and sub forms open in design mode, then open a new query in design mode and from the criteria line use the wizard to locate an object on the form you're trying to requery, use the generated reference ie something like

Forms![frmMain]![frmSchoolGroupView].Form![frmSchoolViewSub].Requery


David
 
in terms of requerying a subform, all you bneed (from the main from) is

mySubFormControlName.Requery
 

Users who are viewing this thread

Back
Top Bottom