By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Access field from Report Recordset

TheSmileyCoder
Expert Mod 100+
P: 2,321
I have a field tx_Value which I want to use in some Detail_Format event.

However if I try using:
Expand|Select|Wrap|Line Numbers
  1. Me.tx_Value
I get an error msg "Method or Data Menber not found"

If I try either of these
Expand|Select|Wrap|Line Numbers
  1. me.recordset.tx_Value
  2. me.recordset!tx_Value
I simply get a printed "Error" in my report, no error msg.

I have a textbox in my report with controlsource=strTenderDoc()
Expand|Select|Wrap|Line Numbers
  1. Private Function strTenderDoc() As String
  2.     strTenderDoc = Me.Recordset!tx_Value
  3. End Function
(The "real" code I want to run is a bit more complicated, but im stumped at accessing the value of tx_Value, so ive simplified the problem to look at that.

Now, I know I can access the tx_Value if I were to make a textbox tb_Value, with the controlsource tx_Value, and just tb_Value in my code. However, I would prefer not to have to make 4 hidden textboxes if it could be avoided.

So how can I access a field from my recordset within the detail_Format, without adding it as a textbox?
Feb 19 '10 #1
Share this Question
Share on Google+
8 Replies


nico5038
Expert 2.5K+
P: 3,072
Hmm, why so much effort. I normally place the coding needed in the report query and use the result in my detail section.

Nic;o)
Feb 19 '10 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
Because sometimes the formatting of an item might depend on the value given in type.

For instance:
Expand|Select|Wrap|Line Numbers
  1. If ID_Type="Header" then
  2.   Code goes here.
  3. end if
Feb 19 '10 #3

nico5038
Expert 2.5K+
P: 3,072
Then I would use the Conditional formatting and select "Expression" for the field that needs the formatting.
Thus you can refer to recordset fields not placed in the detail section, like:
Expand|Select|Wrap|Line Numbers
  1. [Type] <> 5
  2.  
Nic;o)
Feb 19 '10 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
I do alot more then just conditional formatting though. Based on several parameters, I may choose to indent (move the field a bit to right) or sometimes move it downwards a bit. I also check the length of the field, as well as perform a calculation on the estimated length (height really) of the next two fields. If the current item is a header, and I estimate the next item can not be made to fit on the this page, I move the header to the next page. In that way, I dont have Headers at the bottom of hte page, with no text beneath them.


The question still remains, can I access the values in the reports recordset, without adding a textbox?
Feb 19 '10 #5

topher23
Expert 100+
P: 234
I'm pretty sure I've done this before by wrapping the field name in brackets, like

Expand|Select|Wrap|Line Numbers
  1. If [tx_Value]=MyValue Then 'do something
  2.  
but then again, that could just be the brain tumor playing tricks on me...
Feb 19 '10 #6

TheSmileyCoder
Expert Mod 100+
P: 2,321
No luck. Thanks for the try though. :)
Feb 19 '10 #7

nico5038
Expert 2.5K+
P: 3,072
Hmm, much work in rebuilding MS Word functions :-)

Guess you already proved that a direct reference doesn't work, so another way would be to get the needed data by processing the report's recordset directly.
A Dlookup or faster recordset processing (using the unique id of the detail row) is an option, but it will slow down the process.

Guess the hidden fields option is the easy (and fastest) way out.

When I needed some "heavy formatting" in the past I switched to MS Word automation.

Nic;o)
Feb 19 '10 #8

NeoPa
Expert Mod 15k+
P: 31,494
@TheSmileyOne
I think you have your answer now, but in case it's not clear, I believe that the answer is a simple No.

Fields in the underlying (or bound) recordset of the form or report are not accessible directly. The usual method to get around this is the one you've already found, hidden controls, which is somewhat clumsy I agree.
Feb 21 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.