473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dlookup multi criteria

Access 2003

using dlookup to make a button visible.
FYI MSPContactUserID(same as Environ("username"))

table t41ContactMSP looks like this
Expand|Select|Wrap|Line Numbers
  1. MSPContactID(PK)  MSPTitleID  MSPContactUserID
  2.   1                      1              smitha
  3.   2                      3              smitha
  4.   3                      1              jonesb
  5.   4                      2              bakerc
  6.   5                      2              smitha
smitha has many titles.

Need to verify the Environ("username") has the same MSPContactID as the ContactPMgrID (ContactPMgrID is field on form) then verify that it is the correct MSPTitleID (1). How can I make it meet all criteria?

Here is the issue. it finds the first instance of the MSPContactUserID and stops there, it does not take into account that the MSPTitleID must me 1.

Expand|Select|Wrap|Line Numbers
  1. Me!fClosureApproval.Form.btnApprClose.Visible = DLookup("[MSPContactID]", "[t41ContactsMSP]", _
  2.     "[MSPContactUserID] = '" & Environ("username") & "'") = Me.ContactPMgrID _
  3.     & "' And [MSPTitleID] = '" & 1
Mar 3 '11 #1
2 2137
patjones
931 Expert 512MB
Hi Deb,

The problem here is with the check for [MSPTitleID] at the end of the line. VBA does not know that you are referring to a column in a table in your database. That check is outside the context of the DLookup call.

I would suggest trying this instead:

Expand|Select|Wrap|Line Numbers
  1. Me!fClosureApproval.Form.btnApprClose.Visible = (DLookup("[MSPContactID]", "[t41ContactsMSP]", "[MSPContactUserID] = '" & Environ("username") & "' AND [MSPTitleID] = 1) = Me.ContactPMgrID)

Let me know how it works out.

Pat
Mar 3 '11 #2
NeoPa
32,556 Expert Mod 16PB
As Pat says, you need to include all the Criteria for the lookup in the Criteria (third) parameter of the DLookup() call.
Mar 4 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
4
by: ShyGuy | last post by:
I have a table with 4 fields. Three are used for criteria. I can get the DLookup to work with 1 criteria with the following but can't get it to work with 2 or three. NumofAppts = DLookup("",...
6
by: bjaj | last post by:
Hi How do I use a boolean criterian with the funktion DLookup ? I know the syntax for strings, numeric and date as follows For numerical values: DLookup("FieldName" , "TableName" ,...
1
by: MLH | last post by:
I have a query that looks up records in tblReturnReceipts and other related tables. One of the other tables is tblCorrespondence. The resulting dynaset consists of five records. Each has a unique ...
10
by: molen malat | last post by:
i have a query with 4 fields, and a form based on it. i put another 4 textbox to get criteria to filter the query. the query runs normally when all the textbox have a value (not null) but when one or...
3
MSeda
by: MSeda | last post by:
I have a loop that is controlled by a Dlookup statement with two criteria. Both criteria fields are checkboxes. I have tried an assortment of quotation marks in the criteria section and cannot get...
1
by: deejayquai | last post by:
Hello I'm trying to append a series of values into fields from one table to another based on highlighted rows in a multi-select listbox. I'm stuck however when I need to append a couple of...
2
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a...
1
by: Constantine AI | last post by:
Hi i am trying to get User input if data does not exist within a DLOOKUP table. I have gotten it to work for one record but not multiple, i have tried to incorporate my code into a loop procedure but...
1
by: Brendan Wolf | last post by:
Happy Halloween all, I have been struggling at work with a DLookup using multiple criteria. I would like a text box to display the results of a DLookup based on the values selected in three...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.