macro for making a field value determined by the value of another field

K

kennethburr

I am tried to write a macro (I don't know code) in Microsoft Access
2003 that will place a certain value in a field#2 depending on what
value is in field#1. For example if the value in field#1 is any number
between 0 and 100 then the value of field#2 will be 1, and if the value
of field#1 is any number between 101 and 200 then the value of field#2
will be 3, and if the value of field#1 is any number between 201 and
300 then the value of field#2 will be 10. I just joined this group so
my question may not be in the right format, but I would greatly
appreciate any help.
 
A

arthurjr07

Use RunSQL macro to run this SQL script.

UPDATE Table1 Set Table1.FIELD2 =
IIf(([Table1]![FIELD1]>0 And [Table1]![FIELD1]<101),1,
IIf(([Table1]![FIELD1]>101 And [Table1]![FIELD1]<201),3,
IIf(([Table1]![FIELD1]>201 And [Table1]![FIELD1]<301),10,0)));

hope this will help
 
K

kennethburr

Your suggestion not only works great, but I actually got it to work on
the first try! Thanks very much for your help!
 

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