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
-
Outdated Laptop
by
jdamkeene
1 hour, 39 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
7 hours, 4 minutes ago -
Another big Microsoft layoff
by
Charlie
6 hours, 43 minutes ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
6 hours, 32 minutes ago -
May 2025 updates are out
by
Susan Bradley
7 hours, 8 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
12 hours, 47 minutes ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
12 hours, 49 minutes ago -
Drivers suggested via Windows Update
by
Tex265
12 hours, 40 minutes ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
10 hours, 24 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
19 hours, 40 minutes ago -
Apple releases 18.5
by
Susan Bradley
14 hours, 5 minutes ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
21 hours, 6 minutes ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
21 hours, 43 minutes ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
4 hours, 59 minutes ago -
No HP software folders
by
fpefpe
1 day, 5 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
2 hours, 44 minutes ago -
Stay connected anywhere
by
Peter Deegan
1 day, 10 hours ago -
Copilot, under the table
by
Will Fastie
1 day, 2 hours ago -
The Windows experience
by
Will Fastie
1 day, 17 hours ago -
A tale of two operating systems
by
Susan Bradley
38 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
1 day, 22 hours ago -
Where’s the cache today?
by
Up2you2
2 days, 13 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 days, 6 hours ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
1 day, 6 hours ago -
Blocking Search (on task bar) from going to web
by
HenryW
9 hours, 1 minute ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
3 days, 6 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
3 days, 7 hours ago -
regarding april update and may update
by
heybengbeng
3 days, 8 hours ago -
MS Passkey
by
pmruzicka
2 days, 10 hours ago -
Can’t make Opera my default browser
by
bmeacham
3 days, 16 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.