Formula help

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

Guest

I don't reall have any idea on how to write formulas so any help would be
greatly appreciated. I think that I need an if/then formula because what I
am trying to do is:

if [PART1]=[PART2] then display partnumber and if [PART1] does not =[PART2]
disply nothing.

Thank you
 
Try the IIf() function. The general syntax is IIf(condition to test, result
if true, result if false). So for your example, it might look something like
....

IIf([Part1] = [Part2], [PartNumber], "")

See 'IIf() Function' in the help file for more details.
 
you've defined the "formula" almost completely, the only omission being that
you are not specific as to which partnumber to display when the two are
equal - part1 or part2?

and you're correct that an IIf() function will work in this situation.
suggest you read up on the IIf() function in Access Help. separate your
statement "if [PART1]=[PART2] then display partnumber and if [PART1] does
not =[PART2]
disply nothing" into the expression that will be evaluated as true or false,
the section that says which field will be returned if the expression is
true, and the section that says what will be returned if the expression is
false - then put those sections into the IIf() function. if you have
problems getting it to work, post back with your completed IIf() function,
and we'll help you troubleshoot it.

hth
 
ok. think that I understood the access help section and here is the statement:
IIf([qry_DEVICE Query]![PART_ID]=[DEVICE Query]![PART_ID],[qry_DEVICE
Query]![PART_ID],[Nz])

Now when I try to open the report based on this query I get an error message
that says: The specified field '[qry_DEVICE Query].ID' could refer to more
than one tadle listed in the FROM clause of your SQL statement

any ideas???

tina said:
you've defined the "formula" almost completely, the only omission being that
you are not specific as to which partnumber to display when the two are
equal - part1 or part2?

and you're correct that an IIf() function will work in this situation.
suggest you read up on the IIf() function in Access Help. separate your
statement "if [PART1]=[PART2] then display partnumber and if [PART1] does
not =[PART2]
disply nothing" into the expression that will be evaluated as true or false,
the section that says which field will be returned if the expression is
true, and the section that says what will be returned if the expression is
false - then put those sections into the IIf() function. if you have
problems getting it to work, post back with your completed IIf() function,
and we'll help you troubleshoot it.

hth


uuhhgg said:
I don't reall have any idea on how to write formulas so any help would be
greatly appreciated. I think that I need an if/then formula because what I
am trying to do is:

if [PART1]=[PART2] then display partnumber and if [PART1] does not =[PART2]
disply nothing.

Thank you
 
first of all, have you tried opening the query by itself, apart from the
report? it's possible that something in the report is causing the error
message. if you've ruled out that possibility, then look at part of each
field reference to make sure you've spelled everything correctly. also,
suggest you replace the bang (!) characters in the expression with dot (.)
characters.

hth


uuhhgg said:
ok. think that I understood the access help section and here is the statement:
IIf([qry_DEVICE Query]![PART_ID]=[DEVICE Query]![PART_ID],[qry_DEVICE
Query]![PART_ID],[Nz])

Now when I try to open the report based on this query I get an error message
that says: The specified field '[qry_DEVICE Query].ID' could refer to more
than one tadle listed in the FROM clause of your SQL statement

any ideas???

tina said:
you've defined the "formula" almost completely, the only omission being that
you are not specific as to which partnumber to display when the two are
equal - part1 or part2?

and you're correct that an IIf() function will work in this situation.
suggest you read up on the IIf() function in Access Help. separate your
statement "if [PART1]=[PART2] then display partnumber and if [PART1] does
not =[PART2]
disply nothing" into the expression that will be evaluated as true or false,
the section that says which field will be returned if the expression is
true, and the section that says what will be returned if the expression is
false - then put those sections into the IIf() function. if you have
problems getting it to work, post back with your completed IIf() function,
and we'll help you troubleshoot it.

hth


uuhhgg said:
I don't reall have any idea on how to write formulas so any help would be
greatly appreciated. I think that I need an if/then formula because
what
I
am trying to do is:

if [PART1]=[PART2] then display partnumber and if [PART1] does not =[PART2]
disply nothing.

Thank you
 
Back
Top