Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ControlSource Property 1

Status
Not open for further replies.

l7square01

Programmer
Jun 4, 2004
5
0
0
US
I am new to ms access. I am trying to display a calculated value in a text box. The calculated field name is PageSum. In the ControlSource property I set it to: =[PageSum], but it appears that the PageSum variabe is not recognizable to the text box.
 
I assume that this pagesum field is included in the recordsource of the report...

if it is, then you just need to put: pageSum in the recordsource of the textbox

Crowley - as in like a Crow
 
The PageSum field is not in a table. It is a calculated field using fields in a table. I looked at the recordsource feature, I think this of for tables, or bound fields. My field is not defined in any tables or query.
 
Is your form bound or unbound? If it is bound to a query, calculate this value in the query, call it PageSum, and then do as Crowley16 said and put "PageSum" in the control source.


Explain a bit more detail if we are missing the mark.

___________________________________________________________
With your thoughts you create the world--Shakyamuni Buddha
 
The report is a bound report, but the PageSum field is user defined in the VB code builder. I can display all of the bound fields, it is the user defined field that I defined in the VB code builder that I can not dispay in a text box. PageSum is calculated by using a bound field on the report, but I want to display the calculated field which is not in my database table(I created it in the VB code builder).
 
You cannot reference a variable directly from a text box, you need a wrapper function to return the variable to the report.

Be sure that PageSum is declared in the declarations section of your module (before all of the other Procedures).

Then you can write a function to return the value.

Private Function GetPageSum() As Integer
GetPageSum = PageSum
End Function

Change Integer to the data type of PageSum.

Then in the ControlSource of your text box you can call the function:

=GetPageSum()

Good luck

-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top