basics -- using dlookup

  • Thread starter Thread starter robboll
  • Start date Start date
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
 
?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.
 
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.
 
Back
Top