DLookup (1 Viewer)

archiecone

Registered User.
Local time
Today, 21:01
Joined
Jan 30, 2001
Messages
20
Can anyone help me out with this function??

From my understanding it will look at values in a field based on criteria that you give it. Does it work with only one record or all the records in the domain?

here is an example of what I have wrote

var3 = DLookup(("cablesize1"), "voltage drop", rs3.Fields("calcamp").Value <= rs3.Fields("amp1").Value)

where cablesize1 is a field in the voltage drop table. And i want the value where amp1 is greater than calcamps.


Can anyone help me out.

Thanks a lot.

[This message has been edited by archiecone (edited 03-12-2001).]
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:01
Joined
Feb 19, 2002
Messages
43,484
DLookUp() is a function and functions are intended to return only a single value. Therefore, you may have difficulty using it if the specified selection criteria may return more than one row. The "<=" relational operator in your example is a clue that you are not specifying a unique identifier and therefore, multiple rows in the table might satisfy the selection criteria.
 

archiecone

Registered User.
Local time
Today, 21:01
Joined
Jan 30, 2001
Messages
20
I did not say that I wanted to return more than one value. I said I wanted to return a single value.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:01
Joined
Feb 19, 2002
Messages
43,484
I know you didn't "say" you want to return multiple rows. You "said" you needed help. I merely pointed out that a relational operator of "<=" has the "potential" to select more than one row and if it does, the DLookUp will not work as expected. You need to supply an "exact" key so you can use "=" as the RO. I don't have an easy solution. I think you'll need to write some VBA code to search for an appropriate record rather than using a DLookUp().
 

archiecone

Registered User.
Local time
Today, 21:01
Joined
Jan 30, 2001
Messages
20
Dlookup will return the first value that satisfies the criteria.
 

Users who are viewing this thread

Top Bottom