Re: Multiple criteria DLookup

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Renee (Renee_at_discussions.microsoft.com)
Date: 02/10/05


Date: Thu, 10 Feb 2005 08:49:08 -0800

Thank you Wayne!

Though, I have a new error now:

    Run-time error 2001: You Canceled the previous operation
When I select debug, it highlights the variant DLookup statement.

Thanks for your patience,
Renee

"Wayne Morgan" wrote:

> The way you have it coded indicates that the values should be text. Try this
> instead.
>
> varQuantity = DLookup("[Quantity]", "Orders", "[EmpID]=" & [ID] & " And
> [Week#]=" & [Week#])
>
> Basically, just removing the single quotes.
>
> --
> Wayne Morgan
> MS Access MVP
>
>
> "Renee" <Renee@discussions.microsoft.com> wrote in message
> news:A4AE8C79-E68B-4F86-8F18-F5A45DE1120E@microsoft.com...
> > Good Morning,
> >
> > I am receiving a "Data type mismatch in criteria expression" error from
> > the
> > following code (On the OnExit event of the field Week#):
> >
> > Dim varQuantity As Variant
> > varQuantity = DLookup("[Quantity]", "Orders", "[EmpID]='" & [ID] &
> > "'And[Week#]='" & [Week#] & "'")
> > If (Not IsNull(varQuantity)) Then Me![Total] = varQuantity
> >
> > The fields are numbers on both the table and the form. Any suggestions?
> >
> > Thank you in advance as always!
> > Renee
> >
>
>
>



Relevant Pages