Calling a value from a form

D

Doug Sanders

I have a form that when a button is used opens a report.

The form has a field that references a value in a table the is needed on the
report.

On the report control source I have the following:

=DLookUp("[CCIT]","CLIENT NAMES","[CACCTN] = " &
[Forms]![f_New_Case_Input_97]![CACCTN])

It gives me a #ERROR value.

The following line returns the correct result where "104" (a string, not a
number is correct)

=DLookUp("[CCNAM]","CLIENT NAMES","[CACCTN] = '104'")

I am out of ideas of this what should be a simple reference operation.

Any help appreciated.

Doug Sanders
 
F

fredg

I have a form that when a button is used opens a report.

The form has a field that references a value in a table the is needed on the
report.

On the report control source I have the following:

=DLookUp("[CCIT]","CLIENT NAMES","[CACCTN] = " &
[Forms]![f_New_Case_Input_97]![CACCTN])

It gives me a #ERROR value.

The following line returns the correct result where "104" (a string, not a
number is correct)

=DLookUp("[CCNAM]","CLIENT NAMES","[CACCTN] = '104'")

I am out of ideas of this what should be a simple reference operation.

Any help appreciated.

Doug Sanders

If [Caccin] is a Text datatype, you must enclose it's criteria value
within single quotes, just as your = '104' is enclosed.

=DLookUp("[CCIT]","CLIENT NAMES","[CACCTN] = '" &
[Forms]![f_New_Case_Input_97]![CACCTN] & "'")
 
A

Al Campagna

Doug,
No need for a DLookup if the form is still open when the report runs. You can refer to
it directly.
A calculated field on the report with a ControlSource of...
= [Forms]![f_New_Case_Input_97]![CACCTN]
will display that value from the form.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
A

Allen Browne

Since CACCTN is a Text field, add the extra quotes into the Criteria string:

=DLookUp("[CCIT]", "CLIENT NAMES", "[CACCTN] = """ &
[Forms]![f_New_Case_Input_97]![CACCTN] & """")
 

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