"if" statements

A

Alberta Rose

I have a convoluted issue and I hope I can describe it clear. I have a form
(frmCloseout) that is fed from a query (qryLink). In the design mode of the
form, the "detail" area shows one line. When you run the report, all the
information for that contract comes in and has multiple lines on the report
view. Now I need to do some calculations to show up in the detail area of
the form, but need to have my query recognize a specific cost code/cost type
(the first two boxes in the detail line), and if this cost code/cost type is
true, then perform a calculation that includes manhours which are located in
the report header area of the form. If it is false, then continue to the
next cost code/cost type and check that. I know I need to add the formula to
the qryLink, but have no idea how to do it. Anyone want to tackle this with
me :)
 
P

Pendragon

One question for clarification is the "false" part - when you say that you
want to "continue to the next cost code/cost type and check that", do you
mean to say that for the current record which has been evaluated as false,
you want the result for that "false" record to be blank/null/do nothing? To
me, when you say continue, that means going to the next record.

Try this:

MyFieldName: IIf([Cost Code/Cost Type field] = -1, insert calculation here,
Null)

Where I have Null, you could put zero as well if you want to have a value in
the field.

HTH
 
A

Alberta Rose

Yes, i want it to continue and look at the next record. Then on to the next
until it finds a match and run the formula on that record, then onto the
next, etc.


Pendragon said:
One question for clarification is the "false" part - when you say that you
want to "continue to the next cost code/cost type and check that", do you
mean to say that for the current record which has been evaluated as false,
you want the result for that "false" record to be blank/null/do nothing? To
me, when you say continue, that means going to the next record.

Try this:

MyFieldName: IIf([Cost Code/Cost Type field] = -1, insert calculation here,
Null)

Where I have Null, you could put zero as well if you want to have a value in
the field.

HTH

Alberta Rose said:
I have a convoluted issue and I hope I can describe it clear. I have a form
(frmCloseout) that is fed from a query (qryLink). In the design mode of the
form, the "detail" area shows one line. When you run the report, all the
information for that contract comes in and has multiple lines on the report
view. Now I need to do some calculations to show up in the detail area of
the form, but need to have my query recognize a specific cost code/cost type
(the first two boxes in the detail line), and if this cost code/cost type is
true, then perform a calculation that includes manhours which are located in
the report header area of the form. If it is false, then continue to the
next cost code/cost type and check that. I know I need to add the formula to
the qryLink, but have no idea how to do it. Anyone want to tackle this with
me :)
 
P

Pendragon

That's what I had guessed, so try out my suggestion. Post back if you need
more.

Alberta Rose said:
Yes, i want it to continue and look at the next record. Then on to the next
until it finds a match and run the formula on that record, then onto the
next, etc.


Pendragon said:
One question for clarification is the "false" part - when you say that you
want to "continue to the next cost code/cost type and check that", do you
mean to say that for the current record which has been evaluated as false,
you want the result for that "false" record to be blank/null/do nothing? To
me, when you say continue, that means going to the next record.

Try this:

MyFieldName: IIf([Cost Code/Cost Type field] = -1, insert calculation here,
Null)

Where I have Null, you could put zero as well if you want to have a value in
the field.

HTH

Alberta Rose said:
I have a convoluted issue and I hope I can describe it clear. I have a form
(frmCloseout) that is fed from a query (qryLink). In the design mode of the
form, the "detail" area shows one line. When you run the report, all the
information for that contract comes in and has multiple lines on the report
view. Now I need to do some calculations to show up in the detail area of
the form, but need to have my query recognize a specific cost code/cost type
(the first two boxes in the detail line), and if this cost code/cost type is
true, then perform a calculation that includes manhours which are located in
the report header area of the form. If it is false, then continue to the
next cost code/cost type and check that. I know I need to add the formula to
the qryLink, but have no idea how to do it. Anyone want to tackle this with
me :)
 
A

Alberta Rose

Thanks, I'm unsure of where to put this code. Should it be in the box on my
report? Or in my query? Or ???

txtEstPerMhr: IIf([CostCode/CostType field]=-1,
txtEstimatedCost/txtCraftLabEst, nul)

or would I write it as:

txtEstPerMhr: IIf([013210/05320]=-1, txtEstimatedCost/txtCraftLabEst, nul)

Cost code and cost type are not in the same field, but both have to match
before the formula is run.

Thanks for your help with this :)



Pendragon said:
That's what I had guessed, so try out my suggestion. Post back if you need
more.

Alberta Rose said:
Yes, i want it to continue and look at the next record. Then on to the next
until it finds a match and run the formula on that record, then onto the
next, etc.


Pendragon said:
One question for clarification is the "false" part - when you say that you
want to "continue to the next cost code/cost type and check that", do you
mean to say that for the current record which has been evaluated as false,
you want the result for that "false" record to be blank/null/do nothing? To
me, when you say continue, that means going to the next record.

Try this:

MyFieldName: IIf([Cost Code/Cost Type field] = -1, insert calculation here,
Null)

Where I have Null, you could put zero as well if you want to have a value in
the field.

HTH

:

I have a convoluted issue and I hope I can describe it clear. I have a form
(frmCloseout) that is fed from a query (qryLink). In the design mode of the
form, the "detail" area shows one line. When you run the report, all the
information for that contract comes in and has multiple lines on the report
view. Now I need to do some calculations to show up in the detail area of
the form, but need to have my query recognize a specific cost code/cost type
(the first two boxes in the detail line), and if this cost code/cost type is
true, then perform a calculation that includes manhours which are located in
the report header area of the form. If it is false, then continue to the
next cost code/cost type and check that. I know I need to add the formula to
the qryLink, but have no idea how to do it. Anyone want to tackle this with
me :)
 

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