Dlookup not assigning variable

J

Jeffiec

I have the following statements in some code;
(at the begining of the procedure)
Dim awt As Variant

(later in the procedure)
awt = DLookup(rs.Fields("BatchRecords\ActualWeight_" & tel), "BatchRecords",
rs1.Fields("QIMS_" & tel) = rs.Fields("BatchRecords\QIMS_" & tel))

when i stop the code after this statement, and mouseover the rs.fields
statements, i get the proper answers to my dlookup, but awt is never assigned,
its always "Empty"???? Any Clues??

BTW, this runs in a loop statement and my answers are always correct, they
just dont get assigned to awt.
What am I doing wrong?
Thanks in advance

JeffC
 
V

Van T. Dinh

Put a break on the posted code and check the following:

1. The value of rs.Fields("BatchRecords\ActualWeight_" & tel) is a *Field
name*, not value, in the Table (or Query) "BatchRecords"

2. The value of rs.Fields("QIMS_" & tel) is a *Field name*, not value in the
Table (or Query) "BatchRecords".

3. If both 1 & 2 are correct, then the Field referred to in 2 must be a
numeric Field (from the syntax you used).

4. The value of rs.Fields("BatchRecords\QIMS_" & tel) is a *numeric value*
that exists in the Field referred to in 2 in at least one of the Record in
the Table (or Query) "BatchRecords".

Yoy can put a break on the posted code and simply enter:

?DLookup(rs.Fields("BatchRecords\ActualWeight_" & tel), "BatchRecords", _
rs1.Fields("QIMS_" & tel) = rs.Fields("BatchRecords\QIMS_" & tel))

to see if DLookUp returns a non-Null value.

If you are not sure, check Access Help on the syntax of DLookUp.
 
Top