How do I pass a string parameter from a Form (frmStartup)to a Report. In frmStartup I define the string as
strDateRange = “For the Period ” & StartDate & ” To ” & StopDate
A command button then initiates the report, i.e.
DoCmd.OpenReport stDocName, acViewNormal
I want to put strDateRange in the report header; however, the DoCmd.OpenReport doesn’t have any place to put an argument to pass to the Report module.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Passing Parameter to Report
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Passing Parameter to Report
- This topic has 6 replies, 3 voices, and was last updated 24 years ago.
AuthorTopicWSChuck Tucker
AskWoody LoungerApril 30, 2001 at 3:25 am #355529Viewing 0 reply threadsAuthorReplies-
WSBrian Swann
AskWoody Lounger -
WSChuck Tucker
AskWoody LoungerApril 30, 2001 at 2:18 pm #524608Hi Brian,
That’s exactly what I tried, and my report displays #Error in the text box with =Forms![frmStartup]![strDateRange] in it. I’m really puzzled with this one
In the Sub that calls the report I have Dim strDateRange As String. I then have the expression strDateRange = “For The Period ” & Starttxt & ” To ” & Stoptxt. Starttxt and Stoptxt are the names of text boxes that have the dates.
What am I missing? BTW I’m running Access97.
-
WSThomasW
AskWoody LoungerApril 30, 2001 at 3:07 pm #524612I don’t understand why you are using a sub with the expression =Forms![frmStartup]![strDateRange], when it seems that the textboxes on the form are named Starttxt and Stoptxt. Have you tried putting a textbox on the report with the source as =”For The Period ” & Forms![frmStartup]![Starttxt] & ” To ” & Forms![frmStartup]![Stoptxt]?
-
WSChuck Tucker
AskWoody LoungerApril 30, 2001 at 4:50 pm #524619OK,
Confessions of a newbie to the world of VBA. Now you’re forcing me to get down to the real crux of the problem. The string =”For the Period ” & [Forms]![frmStartup]![Starttxt] & ” To ” & [Forms]![frmStartup]![Stoptxt] works just fine EXCEPT, the reports come out with an extra blank page. Of course, this is usually an indication that the report width exceeds the distance between the left and right margins. Soooo, I checked and sure enough, it was too wide. I tried to drag the right edge of the report back to the left, but it won’t budge. Guess what? In the design view the above string runs right off the right edge of the report even though when printed it fits on the page. I then tried to manually set the report width property to the max available space. However, looking back after supposedly saving that entry I find that Access took upon itself to revise it back where it was!!!Of course, I could print in a smaller font — small enough so that the string in design view would fit on the page, but having to accommodate an obvious flaw in Access really bugs me.
So, my thought was to set up the string as a variable in the form with the calling procedure and use that variable in the report text box because it would be shorter in the report design review. It seems like such a simple concept. Can’t a called report acquire variables defined in the calling form? There MUST be a way.
-
WSThomasW
AskWoody LoungerApril 30, 2001 at 6:52 pm #524632Maybe I am misunderstanding you, but the width of the textbox in the design view does not need to accomodate the entire length of the source statement, only the width required for the data to print on the report. So, try decreasing the width of the textbox in the design view, so that it prints on the report properly, but doesn’t exceed the page width.
Then, of course, there is the obvious solution of moving it somewhere else on the page. If the page is 8.5″x 11″ wide – can’t it fit somewhere else? -
WSChuck Tucker
AskWoody LoungerApril 30, 2001 at 7:23 pm #524634Thanks Thomas,
That did it, and the reports all come out looking great.
I don’t know why I didn’t think of it.
However, I remain curious as to how one passes a variable from one object to another. I’m just a beginner regarding Visual Basic and right now I’m slugging my way through VB 6.0 for Dummies which has been helpful but doesn’t cover everything. I’ll figure it out someday.
Thanks again for your patience with a newbie.
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Auto Time Zone Adjustment
by
wadeer
3 hours, 3 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
43 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
8 hours, 54 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
1 minute ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
3 minutes ago -
Apps included with macOS
by
Will Fastie
44 minutes ago -
Xfinity home internet
by
MrJimPhelps
13 hours, 46 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
1 hour, 58 minutes ago -
Debian 12.11 released
by
Alex5723
1 day ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 3 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
7 hours, 19 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
1 day ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 20 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 11 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
1 day, 23 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 15 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
23 hours, 17 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
1 hour, 14 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 8 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days, 5 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 19 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
2 days, 22 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 6 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
19 hours, 30 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 1 hour ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 1 hour ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 14 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 9 hours ago -
0Patch, where to begin
by
cassel23
3 days, 3 hours ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
3 days, 23 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.