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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup

Status
Not open for further replies.

peljo

Technical User
Mar 3, 2006
91
BG
have the folowing DLookup function :
If DLookup("Suborder", "Orders") = True Then

I need to refine it, to include only the cases when Suborder = True and Audit = False. How could i do it ?
becasue there are cases when both fields are true but i need only the above one
 
If DLookup("Suborder", "Orders","[Audit]=0") = True Then
 
Since this is a DLookup and not a DCount I think you will need to include both fields in the criteria parameter of the function...

If DLookup("Suborder", "Orders","Suborder = True and Audit = False") = True Then

Hope this helps.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
How are ya peljo . . .

Have you ever read about [blue]DLookUp[/blue] in VBE help?
Microsoft said:
[blue]If no record satisfies criteria or if domain contains no records, [purple]the DLookup function returns a Null.[/purple][/blue]
This makes your line of code:
Code:
[blue]   If DLookup("Suborder", "Orders") = True Then[/blue]
. . . ambiguous!

Better would be:
Code:
[blue]  Dim Cri As String
   
   Cri = "[Suborder] = True and [Audit] = False"
   If [purple][b]Not IsNull([/b][/purple]DLookup("[Suborder]", "Orders", Cri)[purple][b])[/b][/purple] Then[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Dlookup returns only one value and in this case it looks like you need "cases" as you wrote. If so, Dlookup is not the answer.
 
Howdy orna . . .

The cases (as you put it), are prescribed in my [blue]Cri[/blue] variable and in code provided by [blue]LonnieJohnson[/blue]. I can't seem to grasp your connotation of [blue] "cases"[/blue] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
I meant to respond to pelgo. When i read the item again, it seams to me that he needs another solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top