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.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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, 1 month 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
-
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
37 minutes ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
1 hour, 49 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
29 minutes ago -
Discover the Best AI Tools for Everything
by
Alex5723
10 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
3 minutes ago -
Rufus is available from the MSFT Store
by
PL1
22 hours, 13 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
1 day ago -
KB5061768 update for Intel vPro processor
by
drmark
6 hours, 47 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
2 hours, 58 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
20 hours, 8 minutes ago -
Office gets current release
by
Susan Bradley
22 hours, 45 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
2 days, 12 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
1 day, 21 hours ago -
Stop the OneDrive defaults
by
CWBillow
2 days, 13 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
2 days, 23 hours ago -
X Suspends Encrypted DMs
by
Alex5723
3 days, 1 hour ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
3 days, 2 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
3 days, 2 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
3 days, 3 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
2 days, 15 hours ago -
Enabling Secureboot
by
ITguy
2 days, 22 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
3 days, 11 hours ago -
No more rounded corners??
by
CWBillow
3 days, 7 hours ago -
Android 15 and IPV6
by
Win7and10
2 days, 20 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
3 days, 23 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
4 days, 2 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
3 days, 20 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
4 days, 9 hours ago -
May preview updates
by
Susan Bradley
3 days, 20 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
3 days, 12 hours ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
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.