Method or Data Member Not Found, but definitely there

M

Matthew DeAngelis

I am having an odd problem with this code:

If Not IsNull(Me.PostMoney) Then
If Me.PostMoneyCompValue Like "Between" Then
stSearchCriteria = stSearchCriteria & Trim("[PostMoney] " &
Me.PostMoneyCompValue & " " & Me.PostMoney & " And " & Me.PostMoney2 &
" " & Me.PostMoneyAndOr & " ")
Else
stSearchCriteria = stSearchCriteria & Trim("[PostMoney] " &
Me.PostMoneyCompValue & " " & Me.PostMoney & " " & Me.PostMoneyAndOr &
" ")
End If
End If

This is the last If statement in a series of If statements structured
in the exact same way, but with different field names. My problem is
that the compiler chokes on Me.PostMoney2, saying 'method or data
member not found', despite the presence of the field. In fact, if I
type Me. to bring up the list of fields, I can double-click PostMoney2
to add it, but the compiler still refuses to recognize it. Previously,
before I added PostMoney2, I was getting the same error in that line
for PostMoney, even though the compiler accepted that field as part of
the If Condition.

Is there any reason why the compiler should acknowledge a field in some
instances and not in others?


Thanks,
Matt
 
T

TC

Try referencing the fields seperately, to be sure which one is being
objected to:

dim v as variant
v = me.postmoney
v = me.postmoney2
etc.

BTW:

- why ' Like "Between" ' ? No point using Like without any wildcards :)

- you say this is the last If statement in a series of If statements
structured in the exact same way, but with different field names. Maybe have
a *single* If statement in a function, and call the function repeatedly,
passing the relevant fieldnames as parameters.

HTH,
TC
 
M

Matthew DeAngelis

TC said:
Try referencing the fields seperately, to be sure which one is being
objected to:

dim v as variant
v = me.postmoney
v = me.postmoney2
etc.

BTW:

- why ' Like "Between" ' ? No point using Like without any wildcards
:)

- you say this is the last If statement in a series of If statements
structured in the exact same way, but with different field names.
Maybe have a single If statement in a function, and call the function
repeatedly, passing the relevant fieldnames as parameters.

HTH,
TC


Matthew DeAngelis said:
I am having an odd problem with this code:

If Not IsNull(Me.PostMoney) Then
If Me.PostMoneyCompValue Like "Between" Then
stSearchCriteria = stSearchCriteria & Trim("[PostMoney]
" & Me.PostMoneyCompValue & " " & Me.PostMoney & " And " &
Me.PostMoney2 & " " & Me.PostMoneyAndOr & " ")
Else
stSearchCriteria = stSearchCriteria & Trim("[PostMoney]
" & Me.PostMoneyCompValue & " " & Me.PostMoney & " " &
Me.PostMoneyAndOr & " ")
End If
End If

This is the last If statement in a series of If statements
structured in the exact same way, but with different field names.
My problem is that the compiler chokes on Me.PostMoney2, saying
'method or data member not found', despite the presence of the
field. In fact, if I type Me. to bring up the list of fields, I
can double-click PostMoney2 to add it, but the compiler still
refuses to recognize it. Previously, before I added PostMoney2, I
was getting the same error in that line for PostMoney, even though
the compiler accepted that field as part of the If Condition.

Is there any reason why the compiler should acknowledge a field in
some instances and not in others?


Thanks,
Matt


Thanks TC, that works just fine, although it is a tad annoying to look
at. Any idea what is causing this problem?

Good catch on the Like Between, by the way :). I will look at creating
a catchall function.


Much Appreciated,
Matt
 
T

TC

Matthew DeAngelis said:
TC said:
Try referencing the fields seperately, to be sure which one is being
objected to:

dim v as variant
v = me.postmoney
v = me.postmoney2
etc.

BTW:

- why ' Like "Between" ' ? No point using Like without any wildcards
:)

- you say this is the last If statement in a series of If statements
structured in the exact same way, but with different field names.
Maybe have a single If statement in a function, and call the function
repeatedly, passing the relevant fieldnames as parameters.

HTH,
TC


Matthew DeAngelis said:
I am having an odd problem with this code:

If Not IsNull(Me.PostMoney) Then
If Me.PostMoneyCompValue Like "Between" Then
stSearchCriteria = stSearchCriteria & Trim("[PostMoney]
" & Me.PostMoneyCompValue & " " & Me.PostMoney & " And " &
Me.PostMoney2 & " " & Me.PostMoneyAndOr & " ")
Else
stSearchCriteria = stSearchCriteria & Trim("[PostMoney]
" & Me.PostMoneyCompValue & " " & Me.PostMoney & " " &
Me.PostMoneyAndOr & " ")
End If
End If

This is the last If statement in a series of If statements
structured in the exact same way, but with different field names.
My problem is that the compiler chokes on Me.PostMoney2, saying
'method or data member not found', despite the presence of the
field. In fact, if I type Me. to bring up the list of fields, I
can double-click PostMoney2 to add it, but the compiler still
refuses to recognize it. Previously, before I added PostMoney2, I
was getting the same error in that line for PostMoney, even though
the compiler accepted that field as part of the If Condition.

Is there any reason why the compiler should acknowledge a field in
some instances and not in others?


Thanks,
Matt


Thanks TC, that works just fine, although it is a tad annoying to look
at. Any idea what is causing this problem?

Good catch on the Like Between, by the way :). I will look at creating
a catchall function.


Hi Matt

Not sure I understand what you mean! Did referencing the fields seperately,
show you which one was being objected to? If so, did you find out why it
was objected to?

Cheers,
TC
 

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