Expression question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an expression equivalent to the IF statement in Excel?

I am trying to change the value of a field when a certain condition is met.

Example...

If field A in a query is Cat and field B is Baby, I want field A to change
the value of Cat to Kitten. This would be ideal but if it is not possible
then could there be a field C created in a query that would return the
result of Kitten based on the above conditions?
 
What you need is an 'update' query.

1. Create a new query in design mode.
2. Add the table you need to update to the query.
3. Add the fields to the bottom pane in the query builder window.
4. On the Microsoft Access toolbar, locate 'Query' and change your query to
an 'update' query.
5. Then enter your criteria in your query fields, like 'Cat' and 'Baby'.
6. Enter what you would like each field to be changed to in the 'update'
block for each field, or leave blank if you don't want to update the other
field(s). In the 'Cat' field, I would enter 'Kitten' in the update block (I
would leave the other field blank because I don't what to change that
value).
7. Run the query, and it will update all records with matching values with
the new value.

Best regards,

Todd Shillam
 
Is there an expression equivalent to the IF statement in Excel?

I am trying to change the value of a field when a certain condition
is met.

Immediate-If. Written as...

IIf(Test expression, result if true, result if false)
 
Yes, it's named IF; but how and where you use it isn't the same.

Your question implies that you are trying to perform data machinations in
fields in a table. Access tables aren't the same as Excel spreadsheets even
though the data presentation may look similar.

In Access forms are used for massaging data. Tables are used for storing
data.

To do what you want, create a form based on the table in question and put
the IF statement into the AfterUpdate event of the control that displays
"field B".

While in the case of Excel, you're pretty safe posting a "comparison"
question into an Access newsgroup, it isn't too smart to post a question
into a newsgroup that demands that potential responders know some totally
different application intimately.

HTH
 

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

Back
Top