A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Dlookup with multiple criteria??



 
 
Thread Tools Display Modes
  #1  
Old May 21st, 2010, 02:52 PM posted to microsoft.public.access
deb
external usenet poster
 
Posts: 898
Default Dlookup with multiple criteria??

access2003

How can I make the textbox field"PassedQGDt" on form f015KeyMilestones"
enabled if MSPContactUserID=Environ("username") and the MSPTitleID=8 (number)

Check the Environ("username") against the MSPContactUserID and the
MSPTitleID=8

The user can have many MSPTitleID's ( it is a role table) and user can have
many roles, so it must search the table for both criteria and not just the
first MSPContactUserID .

Table is "t41ContactsMSP" (PK-MSPContactID number). Table set up like...

MSPContactID.............MSPTitleID.............MS PContactUserID
1.......................................1......... .......................abcabc
2.......................................1......... .......................defdef
3.......................................8......... .......................abcabc


Your help us very appreciated!!!

--
deb
  #2  
Old May 21st, 2010, 04:30 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Dlookup with multiple criteria??

"deb" wrote in message
...
access2003

How can I make the textbox field"PassedQGDt" on form f015KeyMilestones"
enabled if MSPContactUserID=Environ("username") and the MSPTitleID=8
(number)

Check the Environ("username") against the MSPContactUserID and the
MSPTitleID=8

The user can have many MSPTitleID's ( it is a role table) and user can
have
many roles, so it must search the table for both criteria and not just the
first MSPContactUserID .

Table is "t41ContactsMSP" (PK-MSPContactID number). Table set up like...

MSPContactID.............MSPTitleID.............MS PContactUserID
1.......................................1......... .......................abcabc
2.......................................1......... .......................defdef
3.......................................8......... .......................abcabc


Your help us very appreciated!!!



If I've understood you correctly, this would do it:

Me.PassedQGDt.Enabled = _
Not IsNull( _
DLookup( _
"MSPContactID", _
"t41ContactsMSP", _
"MSPTitleID=8 And MSPContactUserID=""" & _
Environ("username") & """" _
) _
)


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old May 21st, 2010, 04:53 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Dlookup with multiple criteria??

Additionally I'd recommend against using the environmental variable to get
the current user. It's not totally reliable as environmental variables can
be changed. Instead add the following module to the database:

' module basGetUser
Option Compare Database
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long

Public Function GetUser() As String

Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long

lngSize = 199
strBuffer = String$(200, 0)

lngRetVal = GetUserName(strBuffer, lngSize)

GetUser = Left$(strBuffer, lngSize - 1)

End Function

then in instead of calling Environ("username") call GetUser().

Ken Sheridan
Stafford, England

deb wrote:
access2003

How can I make the textbox field"PassedQGDt" on form f015KeyMilestones"
enabled if MSPContactUserID=Environ("username") and the MSPTitleID=8 (number)

Check the Environ("username") against the MSPContactUserID and the
MSPTitleID=8

The user can have many MSPTitleID's ( it is a role table) and user can have
many roles, so it must search the table for both criteria and not just the
first MSPContactUserID .

Table is "t41ContactsMSP" (PK-MSPContactID number). Table set up like...

MSPContactID.............MSPTitleID.............M SPContactUserI
1.......................................1........ ........................abcab
2.......................................1........ ........................defde
3.......................................8........ ........................abcabc

Your help us very appreciated!!!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201005/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.