basics -- using dlookup

R

robboll

In its simplest form, I am trying to get dlookup to work from the
debug window.

Just checking to see if a value exists in a table.

Table: Table1
Field: Field1

Values: Alpha, Bravo, Charley, Delta

I want to see if doing a dlookup for "Charley" returns a "True"

Debug Window:

? dlookup("[Field1]", "Table1", "Charley")

It results in a Run Time error '2001': You canceled the previous
operation.

Any help appreciated with this one. Thanks.

RBolling
 
L

Linq Adams via AccessMonster.com

?dlookup("[Field1]", "Table1", "Charley'")

DLookup() doesn't return True/False, it returns the value, in this case, of
[Field1] when the Criteria is met. The reason you're getting the error is
that you don't really have a Criteria set!

"Charley"

is not a Criteria! It has to be something like

"[SomeField] ='Charley'"

and the value of [Field1] would then be returned.

?dcount("[Field1]", "Table1", "[Field1] ='Charley'")

will return Charley if, in fact, it's in the table/field, and NULL if it's
not!

You could use something like

?dcount("[Field1]", "Table1", "[Field1] ='Charley'")

which will return a positive number if Charley is in the table/field or Zero
if not.
 
K

Klatuu

This error usually means either the name of the field or the name of the
domain is not correct. Check you spelling.
In any case, it will not return true or false.
If it finds "Charley", it will return "Charley"; If not, it will return Null.
 

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

Top