Help with DLookUp

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.
 
A

AlCamp

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.
 
J

Joe Cilinceon

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.
 
M

Marshall Barton

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)
 
J

Jedit

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
 
J

Joe Cilinceon

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top