VBA If Function

  • Thread starter Thread starter Ecapodieci
  • Start date Start date
E

Ecapodieci

I am looking to set up a VBA function that looks at a field on a report and
if that field matches the criteria, it displays a dollar amount found in
another field on that form. Example...


If the month found in [forms].[payment].[month] is January or April or July
or October, i want the dollar amount found in [forms].[payment].[check amt]
to populate into the [forms].[payment].[addenda].

If it isnt either of those months, i want it to be blank.


thanks,
e
 
A function procedure is what you want. Create one that will accept
the arguments for the two required fields on your form (the form
doesn't have to be visible but it does have to be open). Let the
procedure resolve the result and return it.

then the control will get it's value by =MyProcedure(MyForm!FieldA,
MyForm!VieldB)

HTH
 
awesome. it works. I had tried that before, but i was writing it incorrectly.
This makes it a lot easier than actually doing it through VB.

thanks!

emanuele

Alex said:
Hi,
try to write in a control source of desired textbox (addenda):
=iif(forms!payment!month="January" or forms!payment!month="April" or
forms!payment!month="July", forms!payment![check amt], null)
I am looking to set up a VBA function that looks at a field on a report and
if that field matches the criteria, it displays a dollar amount found in
[quoted text clipped - 10 lines]
thanks,
e
 
Back
Top