Solved

DLookup with multipul criteria

Posted on 2014-01-14
8
221 Views
Last Modified: 2014-01-14
Trying to get this multicriteria dlookup  to work but I keep getting syntax errors..... any assistance is appreciated.

Thank you.

sAccountNo = DLookup("ActNo", "tOutLab", "Lab = " & "'" & Me.OutLab & "'" & " AND " & "'" & "Office = " & "'" & Me.Office & "'")
0
Comment
Question by:thandel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 39781125
Can you advise what data types are the columns tOutLab and Office in your ActNo table?
Can you advise what controls are Me.OutLab and Me.Office (most likely text boxes, but please double check)
0
 

Author Comment

by:thandel
ID: 39781132
Yes the tOutlab is a string, Office is also a string, Me.Outlab and Me.office are combo boxes.
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 39781138
I find using single quote around text values is easier that endless double quotes, so I'd suggest
sAccountNo = DLookup("ActNo", "tOutLab", "Lab = '" &Me.OutLab & "' AND Office = '" & Me.Office & "'")


Kelvin
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:thandel
ID: 39781143
Thanks but I'm getting a run time error of "you have cancelled the previous operation"
0
 
LVL 25

Expert Comment

by:chaau
ID: 39781144
Depending on how Combo Boxes are created either first or second will work:
sAccountNo = DLookup("ActNo", "tOutLab", "Lab = '" & Me.OutLab.Text & "' AND Office = '" & Me.Office.Text & "'") 

Open in new window

sAccountNo = DLookup("ActNo", "tOutLab", "Lab = '" & Me.OutLab.Value & "' AND Office = '" & Me.Office.Value & "'") 

Open in new window

Explanation: You can create Combo Boxes on the form that display text for the items, but the values for the items will have different codes. In this case the actual value that the tables need to be compared with need to be tested against "Value" property. Most of the time, however, you need to test against "Text" property
0
 

Author Comment

by:thandel
ID: 39781150
Sorry neither is working... I don't think I need that as the following is working:

sAccountNo = DLookup("ActNo", "tOutLab", "Lab = '" & Me.OutLab & "'")

It just the multi-criteria that I can't figure out.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39781155
Chances are the combo uses an ID and displays the text. Try
sAccountNo = DLookup("ActNo", "tOutLab", "Lab = '" & Me.OutLab.Column1 & "' AND Office = '" & Me.Office.Column1 & "'")
0
 

Author Comment

by:thandel
ID: 39781159
Wait sorry you had it above, I had my table mixed.... sorry about that.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question