Yes I have stepped through, and it really isnt giving me an error,
just giving me nothing. It is like there is nothing in the field.
The field it is grabbing is a text field. I have tried addind
another record. The LocID has been changed to an auto number even.
I have tried all different variations and feel like banging my head
on the keyboard because I am sure the code is right... but I can not
figure out why it won't pull the info. I have tried with different
tables and can't get anything to pull. The code is on a button on a
form. I was just wondering if a certain reference needs to be used
to make it work.
This is the fields and what is located in the field
LocID DistListName Location
1 VITAHamptonRoads Hampton Roads
Klatuu said:
Okay, when are you getting the error? Have you run your code in
debug mode stepping through one line at a time to see what is
happening. It could be the DLookup is not the problem. Your code
is correct.
MoonBlosm said:
Thanks for all your help, but it is a numeric field and it is just
the number one.
:
Reread my last post. the syntax is different for numeric and text
fields. Also, are you sure it is exactly a 1 in the field. If it
is a text field, there may be a space or other unprintable
character in the field with it. Open the table, retrieve the field
into a variable, then examine it to determine exactly what it is.
:
But there is something in the field, why does it not return the
value?
:
Is [LocID] a numeric field? If not, change your last argument
to "[LocID] = '1'"
Other than that, your code looks fine. The empty you are
getting is probably because if the DLookup doesn't find a match,
it returns Null. EmailAll will then be Null and can evaluate to
Empty depending on how you are using it.
:
Dim EmailAll As Variant
Thanks in advance:
I have this script iin a button
EmailAll = DLookup("[DistListName]", "LocationName", "[LocID] =
1")
Table: LocationName
Field : DistListName in Table LocationName
Filed: LocID in Table LocationName
I keep getting "Empty" when I run the script? Any ideas why
this is working. I only have one record in the table and I
can't get it to work. Does Dlookup only work with certain
references. I have tried leaving off the criteria, still
nothing. HELP!