DLookup using multiple Fields

H

Hoopster

Hi all,

I am trying to lookup a value based on two separate pieces of
information. The following is my code:

varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "'" And "[Operation] = '" & Me.[Operation] & "'").

Rate is a Piece Rate number and is stored in the Table OperationRate as
a Number Value. FlagStyle and Operation are both filled in on the form by the
user and are both Text Fields. I have the same Columns in the Table also as
Text.

When I use the following Code I receive a Run-time error '13': Type
Mismatch. Can someone please tell me where I'm going wrong and steer me in
the right direction?

Thank Ya Kindly

Hoopster
 
K

Klatuu

It is just a syntax error:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And "[Operation] = '" & Me.[Operation] & "'")
 
H

Hoopster

Klatuu,

When I use this code I recieve a Compile error: Expected: list
separator or) with the first notation for [Operation] highlited.


Klatuu said:
It is just a syntax error:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And "[Operation] = '" & Me.[Operation] & "'")

--
Dave Hargis, Microsoft Access MVP


Hoopster said:
Hi all,

I am trying to lookup a value based on two separate pieces of
information. The following is my code:

varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "'" And "[Operation] = '" & Me.[Operation] & "'").

Rate is a Piece Rate number and is stored in the Table OperationRate as
a Number Value. FlagStyle and Operation are both filled in on the form by the
user and are both Text Fields. I have the same Columns in the Table also as
Text.

When I use the following Code I receive a Run-time error '13': Type
Mismatch. Can someone please tell me where I'm going wrong and steer me in
the right direction?

Thank Ya Kindly

Hoopster
 
K

Klatuu

Oops, sorry. This should do it:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And [Operation] = '" & Me.[Operation] & "'")
--
Dave Hargis, Microsoft Access MVP


Hoopster said:
Klatuu,

When I use this code I recieve a Compile error: Expected: list
separator or) with the first notation for [Operation] highlited.


Klatuu said:
It is just a syntax error:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And "[Operation] = '" & Me.[Operation] & "'")

--
Dave Hargis, Microsoft Access MVP


Hoopster said:
Hi all,

I am trying to lookup a value based on two separate pieces of
information. The following is my code:

varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "'" And "[Operation] = '" & Me.[Operation] & "'").

Rate is a Piece Rate number and is stored in the Table OperationRate as
a Number Value. FlagStyle and Operation are both filled in on the form by the
user and are both Text Fields. I have the same Columns in the Table also as
Text.

When I use the following Code I receive a Run-time error '13': Type
Mismatch. Can someone please tell me where I'm going wrong and steer me in
the right direction?

Thank Ya Kindly

Hoopster
 
H

Hoopster

Klatuu,

Beautiful, works like a charm. Thank you so very much.....

Klatuu said:
Oops, sorry. This should do it:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And [Operation] = '" & Me.[Operation] & "'")
--
Dave Hargis, Microsoft Access MVP


Hoopster said:
Klatuu,

When I use this code I recieve a Compile error: Expected: list
separator or) with the first notation for [Operation] highlited.


Klatuu said:
It is just a syntax error:
varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "' And "[Operation] = '" & Me.[Operation] & "'")

--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I am trying to lookup a value based on two separate pieces of
information. The following is my code:

varRate = DLookup("[Rate]", "[OperationRate]", "[FlagStyle] = '" & _
Me.[FlagStyle] & "'" And "[Operation] = '" & Me.[Operation] & "'").

Rate is a Piece Rate number and is stored in the Table OperationRate as
a Number Value. FlagStyle and Operation are both filled in on the form by the
user and are both Text Fields. I have the same Columns in the Table also as
Text.

When I use the following Code I receive a Run-time error '13': Type
Mismatch. Can someone please tell me where I'm going wrong and steer me in
the right direction?

Thank Ya Kindly

Hoopster
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top