invalid reference problem

  • Thread starter Thread starter jason
  • Start date Start date
J

jason

I have a form in an Access Project that has a subform on
it. I am trying to compare the value of a field on that
subform to the results of a function. Here is an example
of what I'm doing:

if DatePart("d", Me.Today!Today) =
DatePart("d", Now()) Then ...

The Me.Today!Today doesn not function as it should,
resulting in the runtime error 2455 'you entered an
expression that has an invalid reference to the property
Form/Report

Any ideas on what is causing this?

Thanks,

Jason
 
This might have to do with the difference between the
subform object and the actual form that is its target.
You would think that a subform is a subform, but there
are two levels of object between the main form and a
field on the subform. If the subform object and its
target (the underlying subform) have different names, it
can be confusing to reference the fields in the subform.
You might need to reference it as: formname.subformname!
[underlying subform form name]![Field Name]. This should
work.

Have you noticed that in design mode, you have to click
twice on a subform to get at its controls? This is
because the first click selects the subform object on the
main form, and the second click selects the underlying
form within the subform object.

Another possibility is the use of the word "today" as a
control name. I am not sure whether "today" is a
reserved word, but it is always best to avoid using names
that could be reserved as control names.
 
j> I have a form in an Access Project that has a
j> subform on it. I am trying to compare the value of
j> a field on that subform to the results of a
j> function. Here is an example of what I'm doing:

j> if DatePart("d", Me.Today!Today) =
j> DatePart("d", Now()) Then ...

j> The Me.Today!Today doesn not function as it should,
j> resulting in the runtime error 2455 'you entered an
j> expression that has an invalid reference to the
j> property Form/Report

j> Any ideas on what is causing this?

open VBA, open References, and verify if they are valid. i.e. if the dll's
exist. One of them most likely is missing.

Vadim
 
Back
Top