Help with DLookUp

  • Thread starter Thread starter Joe Cilinceon
  • Start date Start date
J

Joe Cilinceon

Here is the statement:
=DLookUp("[tblUnitData]![Rate]","[tblUnitData]","[tblUnitData]![Unit] ="
&[Forms]![fsubPostPayments]![Unit])
Now what I'm looking for is the Rate from tblUnitData for the unit that has
focus on the subfrom fsubPostPayments. I keep getting a ?Name error.

Any one have a clue as to what I'm doing wrong. Oh and Unit is a number
field.
 
Joe,
Try...
=DLookUp("[Rate]","[tblUnitData]","[Unit] =
[Forms]![fsubPostPayments]![Unit]")

I think that should do it... as long as ALL the controls and control names
exist and are correctly spelled in the Dlookup syntax. (Rate, tblUnitData,
Unit, etc...)

But, if your sub form is on a main form, and your Statement is called from
there, then that should be indicated in the Dlookup...
=DLookUp("[Rate]","[tblUnitData]","[Unit] =
[Forms]![frmYourMainForm]![fsubPostPayments]![Unit]")
hth
Al Camp

Joe Cilinceon said:
Here is the statement:
=DLookUp("[tblUnitData]![Rate]","[tblUnitData]","[tblUnitData]![Unit] ="
&[Forms]![fsubPostPayments]![Unit])
Now what I'm looking for is the Rate from tblUnitData for the unit that
has
focus on the subfrom fsubPostPayments. I keep getting a ?Name error.

Any one have a clue as to what I'm doing wrong. Oh and Unit is a number
field.
 
Thanks Al but neither worked.

--

Joe Cilinceon


AlCamp said:
Joe,
Try...
=DLookUp("[Rate]","[tblUnitData]","[Unit] =
[Forms]![fsubPostPayments]![Unit]")

I think that should do it... as long as ALL the controls and control names
exist and are correctly spelled in the Dlookup syntax. (Rate, tblUnitData,
Unit, etc...)

But, if your sub form is on a main form, and your Statement is called from
there, then that should be indicated in the Dlookup...
=DLookUp("[Rate]","[tblUnitData]","[Unit] =
[Forms]![frmYourMainForm]![fsubPostPayments]![Unit]")
hth
Al Camp

Joe Cilinceon said:
Here is the statement:
=DLookUp("[tblUnitData]![Rate]","[tblUnitData]","[tblUnitData]![Unit] ="
&[Forms]![fsubPostPayments]![Unit])
Now what I'm looking for is the Rate from tblUnitData for the unit that
has
focus on the subfrom fsubPostPayments. I keep getting a ?Name error.

Any one have a clue as to what I'm doing wrong. Oh and Unit is a number
field.
 
Joe said:
Here is the statement:
=DLookUp("[tblUnitData]![Rate]","[tblUnitData]","[tblUnitData]![Unit] ="
&[Forms]![fsubPostPayments]![Unit])
Now what I'm looking for is the Rate from tblUnitData for the unit that has
focus on the subfrom fsubPostPayments. I keep getting a ?Name error.


You can not use ! between a table name and a field name. If
you needed anything there it would be a .

But, you do not need to specify which table the field is in,
because there is only one table involved in the lookup.

=DLookUp("Rate","tblUnitData","Unit]=" &
Forms!fsubPostPayments!Unit)
 
Here u go Joe
DLookUp("[Rate]","tblUnitData","[Unit]=[Forms]![fsubPostPayments]![Unit]")

if this still does not work then try naming the unit firld on your form to
say txtRate to eliminate confusion.
HTH
Regards
Jed
 
Got it guys I find a typo on one of the object names that was causing it. It
works now and thanks one and all.
 
Back
Top