PC Review


Reply
Thread Tools Rate Thread

dlookup with multiple criteria

 
 
buzzmcduffie
Guest
Posts: n/a
 
      22nd Apr 2010
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
 
Reply With Quote
 
 
 
 
Daryl S
Guest
Posts: n/a
 
      22nd Apr 2010
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

 
Reply With Quote
 
buzzmcduffie
Guest
Posts: n/a
 
      11th May 2010
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DLOOKUP - Multiple criteria GD Microsoft Access Forms 4 5th Mar 2009 12:30 AM
Dlookup using multiple criteria larochy Microsoft Access Forms 2 25th Jan 2009 08:01 PM
DLookup- multiple criteria Jacinda Microsoft Access 7 18th Apr 2008 10:54 AM
Multiple Criteria in DLOOKUP =?Utf-8?B?RGF2aWQ=?= Microsoft Access Form Coding 2 6th Mar 2006 04:19 AM
Multiple criteria in dlookup? clueless Microsoft Access Forms 1 19th Jan 2006 09:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.