The ME is a reference to the form. When used in a Form module, its a
quick way to reference a control or form property as in
Me.txtControlName versus [Forms]![frmReservations]![txtControlName]
But if you have the code in the afterUpdate event of the text box, it
should work without any problems.
Wendy Anderson wrote:
Hi Duane!
I created the table, added the following code you suggested to the necessary
field, and I got an error that says "Can't find macro 'Me' ". Macro or macro
group does not exist..." Maybe I've done something wrong. My new table has
these fields: MinNum, MaxNum, Value.
Thanks for your help.
Wendy
:
In the after update of the text box bound to field1, add this code:
Me.txtField2 = Dlookup("TheValue","tblXYZLookup",Me.txtField1 & ">=MinNum
AND " & Me.txtField1 & " <MaxNum")
--
Duane Hookom
MS Access MVP
Hi Duane! Thanks for your suggestion. I will try that; however, I
already
have this form set up with these fields linked to a table. I'm not real
knowledgeable about linking and relationships between more than one table
in
a form. I just have these two fields I need fixed: For example: when
9.99
is typed in Field1, then Field2 should automatically say .20 .
If I can get this one issue to work, I'll be just about done with my
project
(I think). Thanks for your input!!!
Wendy
:
I hate to send you off in another direction but you should not be
maintaining this "business rule/calculation" in an expression. Consider
creating a table:
tblXYZlookup
==============
MinNum
MaxNum
TheValue
Add records like:
..01 1 .1
1 10 .2
10 25 .35
25 50 .6
etc
You can then add tblXYZLookup to your query use a criteria in you query
like
WHERE XYZ >=MinNum and XYZ<MaxNum
This should select the proper [TheValue] for your expression.
When the min, max, and values change, you don't have to edit an
expression,
you edit data.
--
Duane Hookom
MS Access MVP
So sorry guys!! This is my first time posting help questions on this
forum,
and for that matter, I just found this forum TODAY! Sure glad it's
here,
it's been very helpful.
I did receive two helps on my problem with the If/then code. I tried
putting both suggestions into my field and I just can't get either one
to
work for me. I must be missing some syntax somewhere, and I think that
may
be my whole problem here. This is what I need:
If field1 is .01 to .99, then field2 = .10
If field1 is 1.00 to 9.99, then field2 = .20
If field1 is 10.00 to 24.99, then field2 = .35
If field1 is 25.00 to 49.99, then field2 = .60
And so on until field1 is 500.00 or more. Field2 is the calculated
field
that comes from field1. There are a total of 6 If/thens. Can this be
done
on a one-line formula, (example)
=IIf(Field1) >= .99, (Field1) = .10 : IIf(Field1) between 1.00 and
9.99,
(Field1) = .20)) and so on....
If so, I'm going insane with the brackets and parens, or the lack
thereof!!!
It seems to be simple enough, but I think I have just tried too hard
for
too
long and I'm burnt out with it.
Thanks to you all for your kindness and help!!!
Wendy
:
Yes, (SERIOUSLY) please tell us if what we've suggested doesn't work,
needs some work or is compeletely off base. It is how we ourselves
learn.
Graham R Seach wrote:
Wendy just sent me an email because she didn't like the two answers
suggested. Wendy, please always post follow-up questions to the
newsgroup,
so that everyone can benefit from both the question and the answer.
It's OK
to tell respondents that they didn't provide a suitable answer.
I take it you want a one-line formula.
To arrive at a one-liner, you need to be a tad more specific about
what
X,
XX and XXX are. Is there some numerical progression or mathematical
pattern
to the values you want returned? If not, then this is going to be a
massive
formula!
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
message
The If/then code is a little confusing to me and I'm having trouble
with
another calculated field. If someone could help me (again), I would
be
greatly appreciative!! I keep putting in what I think is the code,
but
I
seem to be missing something in the formula.
Example:
If xyz is .01 - .99, then answer is X
If xyz is 1.00 - 9.99, then answer is XX
If xyz is 10.00 - 24.99, then answer is XXX
(and so on until 500.00 or more)
Thanks so much for any help provided!!!
Wendy