Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-22
2
Medium Priority
?
2,638 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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