Solved

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

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

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
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…

732 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