ahh, so what you are saying is I need to have the field on the report as a textbox?
Main Topics
Browse All TopicsI have a report, I want to add some code behind it but I need to know the value of a field of the current record. How do I get this information?
i.e. for a form, it is simply
me.recordset("Field1").val
I have tried this for a report, and it doesn't work.
I assume this code would go in the Detail_Format sub
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Kinda...
;-)
The issue is that because Access, by default, names the Control the same as the Field.
This can sometimes lead to issues when you specifically want the Field, or you specifically want the Control.
Further complicating matters is the way this works in a form and whether you refer to the field as:
Price
or
=Price
...In the controlsource property of the control.
For example if you say: Me.Country.BackColor=vbred
You mean the "Control"
Access can sometimes interpret this as the Field (because it has the same name) and throw an error, because the "Field" does not have a BackColor Property. (only a control does)
So, to be on the safe side you can put the texbox on the report (And give it a unique name like txtPrice) and reference it, but set the visible property to NO.
The reasoning behind this is that in a Report you will probably need to reference the control more often than you will need to reference the Field itself.
JeffCoachman
thydzik,
Because a Report is meant to "display" values, not reference them, there is no real "Current" record in a Report (this is now changed for Access 2007)
So you can only grab the current value on the Format event of the Report's detail section.
"Formatting" (in the Format Event) involves Controls, not fields, hence the difficulty in retrieving the "Field" value.
I personally tried this several time using seveal different combinations, and I could not get the "Field" value without a corresponding Control also on the report)
Perhaps there is a way, though...
Just curious, ...what's the issue with using a small textbox and hiding it?
:-)
Jeff
Business Accounts
Answer for Membership
by: boag2000Posted on 2009-03-22 at 15:24:51ID: 23953654
thydzik,
On the Format event of the Detail section, something like this:
Dim YourVariable as Your datatype
YourVariable =YourField or Control
For example to get a price use something like this:
Dim currPrice as Currenct
currPrice=me.txtPrice
JeffCoachman