Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access - Assign a table field value to a variable in subreport vba

Posted on 2013-05-22
2
Medium Priority
?
2,669 Views
Last Modified: 2013-05-22
Hello,

In my Microsoft Access database, I have a report object named 'ReportA' and this report contains a subreport named 'ReportB'.

The Control Source of the subreport 'ReportB' is 'TableB'.

The 'TableB' has a field named 'TelephoneNumber'.

In the On Format event (VBA) of the detail area of the subreport 'ReportB', I want to assign the 'TelephoneNumber' field value of the current record to the variable named 'VariableA'.

I have tried:

Dim VariableA

VariableA = [TelephoneNumber]   'Didn't work, I don't know why because this code works on non-SUBreport 

VariableA = Me.[TelephoneNumber] 'Also didn't work

VariableA = Me.TelephoneNumber 'Also didn't work

Open in new window


Can someone please give me the correct code?

Thank you,
0
Comment
Question by:ZKM128
2 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 39189554
You can try referring to it like this:

Me!TelephoneNumber

If that doesn't work, the you can actually add the Field to the report somewhere, and then refer to it. I've found this to be the most foolproof method when I need to refer to a Field in a Report.
0
 

Author Comment

by:ZKM128
ID: 39189641
Thank you LSMConsulting,

Me!TelephoneNumber didn't work but I have created a hidden text box on the subreport and

VariableA = Me.TextBoxName

Open in new window


worked out OK.

I wanted to know the method of accomplishing this without creating the hidden text box but if this is the only way I'll create a hidden text box for all the field values I need.

Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question