Solved

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

Posted on 2013-05-22
2
2,508 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 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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