Sum value from Dlookup function

G

Guest

Hi,

I need to store data in existing form's text box from another form text box
(field value), for which, i used the below codes which are showing "#Name?"...

The codes are..
When i use this code in the existing form's text box's control source,

1.
=DLookUp("[Req_Ded_Amt]","Requisition_Table","[Req_Ded_Amt]=" &
[Forms]![Deduction_Creation]![Total_Amount])

2.
=[Forms]![Deduction_Creation]![Total Amount]

3.
=DLookUp("[Deduction_Tot_Amt]","Deduction_Table",
"[Ded_Req_id]=" & [Forms]![Requisition_Creation]![Requisition_id]

These THREE different cases are giving error.

But instead of this code, i would like to sum the value when i use Dlookup
function. Like, in a table/Form, the fields are Ded_id,Ded_Remarks,Ded_Amt.

When i take Ded_Amt, I need to sum the value based on the id

For which, may I use the code as below.

=DLookUp((Sum("[Deduction_Tot_Amt]")),"Deduction_Table",
"[Ded_Req_id]=" & [Forms]![Requisition_Creation]![Requisition_id]


Pls.suggest me & point out me where i have done mistake.

Thanks in adv...

ngr.
 
J

John W. Vinson

Hi,

I need to store data in existing form's text box from another form text box
(field value), for which, i used the below codes which are showing "#Name?"...

Misconception correction:

You don't store data in Forms.

Forms are JUST WINDOWS. Data is stored in tables, and *only* in tables; it can
be displayed or edited in a Form.
The codes are..
When i use this code in the existing form's text box's control source,

1.
=DLookUp("[Req_Ded_Amt]","Requisition_Table","[Req_Ded_Amt]=" &
[Forms]![Deduction_Creation]![Total_Amount])

2.
=[Forms]![Deduction_Creation]![Total Amount]

3.
=DLookUp("[Deduction_Tot_Amt]","Deduction_Table",
"[Ded_Req_id]=" & [Forms]![Requisition_Creation]![Requisition_id]

These THREE different cases are giving error.

But instead of this code, i would like to sum the value when i use Dlookup
function. Like, in a table/Form, the fields are Ded_id,Ded_Remarks,Ded_Amt.

Well... use the DSum() function instead of the DLookup function then.
When i take Ded_Amt, I need to sum the value based on the id

For which, may I use the code as below.

=DLookUp((Sum("[Deduction_Tot_Amt]")),"Deduction_Table",
"[Ded_Req_id]=" & [Forms]![Requisition_Creation]![Requisition_id]

Guessing completely in the dark here, since I have no idea how your form is
structured... but if you want to see the sum of the Deduction_Tot_Amt field
from the DeductionTable displayed on the form named Requisition_Creation,
which has a control named Requisition_ID:

=DSum("[Deduction_Tot_Amt]", "[Deduction_Table]", "[Ded_Req_ID]= " &
[Requisition_ID])

If Ded_Req_ID is of Text datatype rather than Number or Autonumber, you need
some quotemarks:

=DSum("[Deduction_Tot_Amt]", "[Deduction_Table]", "[Ded_Req_ID]= '" &
[Requisition_ID] & "'")


John W. Vinson [MVP]
 

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