View Full Version : DLookup


archiecone
03-12-2001, 05:56 AM
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
03-12-2001, 04:54 PM
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
03-13-2001, 03:00 AM
I did not say that I wanted to return more than one value. I said I wanted to return a single value.

Pat Hartman
03-13-2001, 05:33 PM
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
03-14-2001, 03:29 AM
Dlookup will return the first value that satisfies the criteria.