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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

dlookup with multiple criteria



 
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2010, 02:53 PM posted to microsoft.public.access.forms
buzzmcduffie
external usenet poster
 
Posts: 35
Default dlookup with multiple criteria

I have a form that needs to look up a "goal" by matching several fields in a
table. I can't figure out how to do dlookup with multiple criteria

frmManualTaskDataEntry
[employee]
[date]
[mailcode]
[state]
[disabilityind]
[volumecode]


tblMailCodeTasks
mailcode
state
disabilityind
state
goal
  #2  
Old April 22nd, 2010, 03:06 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default dlookup with multiple criteria

Buzzmcduffie -

You use AND to connect the multiple criteria, and must include proper
delimeters for text and date fields. It will look something like this
(untested):

DLookup("[goal]","[tblMailCodeTasks]","[mailcode] = '" & Me.mailcode & _
"' AND [state] = '" & me.state & "' AND [disabilityind] = '" & _
me.disabilityind & "'")

You have two 'state' fields listed in your table. If one of them is really
date and you need to include criteria on that, then it would be like this:

DLookup("[goal]","[tblMailCodeTasks]","[mailcode] = '" & Me.mailcode & _
"' AND [state] = '" & me.state & "' AND [disabilityind] = '" & _
me.disabilityind & "' AND [date] = #" & me.[date] & "#")

You really should change the name of the 'date' field to something else as
this is a reserved word in Access, and it can cause problems. For now,
always put that field name in square brackets...

--
Daryl S


"buzzmcduffie" wrote:

I have a form that needs to look up a "goal" by matching several fields in a
table. I can't figure out how to do dlookup with multiple criteria

frmManualTaskDataEntry
[employee]
[date]
[mailcode]
[state]
[disabilityind]
[volumecode]


tblMailCodeTasks
mailcode
state
disabilityind
state
goal

  #3  
Old May 11th, 2010, 12:04 PM posted to microsoft.public.access.forms
buzzmcduffie
external usenet poster
 
Posts: 35
Default dlookup with multiple criteria

What am I doing wrong??
Private Sub cbxCompany_AfterUpdate()
Me![Goal] = DLookup("[Goal]", "tblMailCodeTasks", tblMailCodeTasks.MailCode
= [Forms]![frmManualTasksDataEntry]![cbxMailCodeTask]) And
((tblMailCodeTasks.DisabilityIndicator) =
[Forms]![frmManualTasksDataEntry]![cbxDisabilityIndicator]) And
((tblMailCodeTasks.State) = [Forms]![frmManualTasksDataEntry]![cbxState]) And
((tblMailCodeTasks.Active) = "yes")
End Sub

"Daryl S" wrote:

Buzzmcduffie -

You use AND to connect the multiple criteria, and must include proper
delimeters for text and date fields. It will look something like this
(untested):

DLookup("[goal]","[tblMailCodeTasks]","[mailcode] = '" & Me.mailcode & _
"' AND [state] = '" & me.state & "' AND [disabilityind] = '" & _
me.disabilityind & "'")

You have two 'state' fields listed in your table. If one of them is really
date and you need to include criteria on that, then it would be like this:

DLookup("[goal]","[tblMailCodeTasks]","[mailcode] = '" & Me.mailcode & _
"' AND [state] = '" & me.state & "' AND [disabilityind] = '" & _
me.disabilityind & "' AND [date] = #" & me.[date] & "#")

You really should change the name of the 'date' field to something else as
this is a reserved word in Access, and it can cause problems. For now,
always put that field name in square brackets...

--
Daryl S


"buzzmcduffie" wrote:

I have a form that needs to look up a "goal" by matching several fields in a
table. I can't figure out how to do dlookup with multiple criteria

frmManualTaskDataEntry
[employee]
[date]
[mailcode]
[state]
[disabilityind]
[volumecode]


tblMailCodeTasks
mailcode
state
disabilityind
state
goal

 




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 01:56 PM.


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