DLookup syntax help?

  • Thread starter Thread starter ZBC
  • Start date Start date
Z

ZBC

I am looking for some help with the syntax of a DLookup to retrieve a
table value based on the contents of a combo box on a form:
Table: "tblReten"
Field: "AutoPhyDed"
for: "PolyYr" = (to the contents of combo box "cboYear" on form
"frmClaimSummary"

This is what I tried ...
DLOOKUP("[AUTOPHYDED]","tblReten","[POLYR]"=" &
Forms![frmClaimSummary]!cboYear")


Bob
 
First, you use PolyYr in your definition, but POLYR in the statement -- one
place or the other appears to be in error.

Is this field "POLYR" or "PolyYr" a text field?

If so, then
"[POLYR]=""" & Forms!frmClaimSummary!cboYear & """"
If not, then you need to tell us what type field it is.

The criteria is a string. It might make it easier to follow if you set the
value of a string variable in a separate statement and then used the string
variable in the DLookup.

Larry Linson
Microsoft Access MVP
 
Sorry for the confusion and the typo's!
I'm obviously having several problems (besides typing) in understanding
how to use DLookup! ... and I am very likely going the wrong way!

Before I get things too messed up... let me give details (hopefully more
accurately) about what I am trying to do ...
I am using a form (frmClaimSummary) as a user interface to print a report.
On the form is a combo box (cboYear) where the user selects the year of
the report.
The report source is based on a query (qryClaimSummary).

"tblReten" is a pseudo-constants table in which 'all' of the fields
including "POLYR" and "AUTOPHYDED" are numeric (long integer).
"POLYR" is the key field in the table (tblReten) which contains values
for several years.

In my first step in changing hard-coded constants to table-lookup values ...
I want to use the values contained in the "AUTOPHYDED" field to replace
what is initially a hard-coded constant (the 250) in a calculated query
field:
AUTOPHYDED: IIf([COVERAGE]="AUTOPHY",250,0)
(This currently places 250 in the field everywhere
[Coverage]="AUTOPHY" ... This value actually changes with [POLYR] ...
thus the table lookup.

Thanks for helping ...
Recommendations and Details appreciated!

Bob


Larry said:
First, you use PolyYr in your definition, but POLYR in the statement -- one
place or the other appears to be in error.

Is this field "POLYR" or "PolyYr" a text field?

If so, then
"[POLYR]=""" & Forms!frmClaimSummary!cboYear & """"
If not, then you need to tell us what type field it is.

The criteria is a string. It might make it easier to follow if you set the
value of a string variable in a separate statement and then used the string
variable in the DLookup.

Larry Linson
Microsoft Access MVP



I am looking for some help with the syntax of a DLookup to retrieve a
table value based on the contents of a combo box on a form:
Table: "tblReten"
Field: "AutoPhyDed"
for: "PolyYr" = (to the contents of combo box "cboYear" on form
"frmClaimSummary"

This is what I tried ...
DLOOKUP("[AUTOPHYDED]","tblReten","[POLYR]"=" &
Forms![frmClaimSummary]!cboYear")


Bob
 
Back
Top