Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Criteria DLookUp As a Control Source 1

Status
Not open for further replies.

alanna101207

Technical User
Oct 26, 2007
13
US
Can somebody please tell me where I am going wrong here. I use the following as a Control Source for a text box on a form:

=DLookUp("WeighIn","tbl_Week","ProgramID =" & [txt_ProgramID] & " AND WeekNumber =" & DMin("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID]))-DLookUp("WeighIn","tbl_Week","ProgramID =" & [txt_ProgramID] & " AND WeekNumber =" & DMax("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID]))/DMax("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID])

I am not getting any error's, but I am getting the wrong number according to my math.

I have checked each part of this separately as follows and I am getting the correct numbers:

PART ONE CORRECTLY = (315)
=DLookUp("WeighIn","tbl_Week","ProgramID =" & [txt_ProgramID] & " AND WeekNumber =" & DMin("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID]))

PART TWO CORRECTLY = (285)
DLookUp("WeighIn","tbl_Week","ProgramID =" & [txt_ProgramID] & " AND WeekNumber =" & DMax("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID]))

PART THREE CORRECTLY = (3)
DMax("WeekNumber","tbl_Week","ProgramID =" & [txt_ProgramID])

Should be:
PART THREE (315) "minus" PART TWO (285) "divided by" PART THREE (3)...I think this should equal (10) but I am getting (220) for some reason.

Each part gives the correct number in three separate text boxes, but gives me the wrong answer when I use it all in one text box. I am thinking maybe I need to somehow separate each "part" with brackets or qoutations, but I just haven't been able to figure it out.

I would appreciate any help I can get. Thank you.

 
Use parentheses:
(315-285)/10

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That's it! I sware I tried that and got a syntex error, but I must have put them in the wrong place. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top