-
WSwasihk
AskWoody LoungerHello
I selected the Microsoft Excel 15.0 Object Library….and it did the TRICK
I’m now able to open the report based on filter criteria which I was assigning to the variable zWhere.
I THANK YOU for your efforts, help and support
-
WSwasihk
AskWoody LoungerHello HTH
I appreciate your prompt response, I tried your suggestion but still the same issue, it prompt for inputbox.
Customer is a text field containing business names only.
Wasijk,
Welcome to the Lounge as a new poster! :cheers:
Try it this way:
Code:zWhere = "[Customer] = " & rst![Customer] '*** If Customer is a number use Str(rst![Customer]) 'Assign filter to the report using variable DoCmd.OpenReport zDocname, acViewPreview, , zWhere, acWindowNormal
HTH :cheers:
-
WSwasihk
AskWoody LoungerHello Team
I’m trying to sendan email using your codes, with attachment of XL or PDF, the issue I’m having is when passingvalues using a variable to filter my report or query, it prompt toinput the values!
I have tried it ondifferent machines with different windows and access versions;
Windows 10, Access2013
Windows 7, Access2010
Windows 7, Access2007
Here are the codes after making appropriate changes to work with my db,I tried using docmd with my variable as filter, where “Order_rpt” isreport name, “zWhere” is the criteria/filter, it prompt an inbox toenter value for zWhere!
zWhere is hasstring value (Customer name)Code:Public Sub Daily_eml_rpt() Dim dbName As Database Dim rst As Recordset Dim lRecNo As Long Dim leMlCnt As Long Dim zWhere As String Dim zMsgBody As String Dim zEmail As String Dim zSubject As String Dim zDocname As String 'Asssign Report Name to variable zDocname = "Order_Status_rpt" 'Opens Current database Set dbName = CurrentDb() 'Opens Recordset/Table Set rst = dbName.OpenRecordset("Customer_tbl", dbOpenDynaset) rst.MoveFirst leMlCnt = 0 'Looping through the recordst to assign the customer name to variable Do While Not rst.EOF If rst![email] = "" Then MsgBox "No Data is available for selected date", vbOKOnly, "Daily Order Status" Else zWhere = rst![Customer] 'Assign filter to the report using variable DoCmd.OpenReport zDocname, acViewPreview, , "[Customer] = " & zWhere, acWindowNormal zEmail = rst![email] zSubject = "WPOA Annual Dues Statement: " & rst![Customer] zMsgBody = "Hi " & rst![Customer] & vbCrLf & "Please find your Today's Order Status attached." DoCmd.SendObject acReport, zDocname, acFormatPDF, zEmail, , , zSubject, zMsgBody, True DoCmd.Close acReport, zDocname, acSaveNo leMlCnt = leMlCnt + 1 '*** Count Emails Created *** End If rst.MoveNext '*** Move to Next Record *** Loop MsgBox Format(lBillCnt, "#,###") & " Email Messages Created.", , "Customer Emails" Set rst = Nothing '*** Close RecordSet *** End Sub
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

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
-
Steps to take before updating to 24H2
by
Susan Bradley
3 hours, 55 minutes ago -
Which Web browser is the most secure for 2025?
by
B. Livingston
3 hours, 57 minutes ago -
Replacing Skype
by
Peter Deegan
3 hours, 57 minutes ago -
FileOptimizer — Over 90 tools working together to squish your files
by
Deanna McElveen
1 hour, 26 minutes ago -
Excel Macro — ask for filename to be saved
by
nhsj
7 hours, 22 minutes ago -
Trying to backup Win 10 computer to iCloud
by
SheltieMom
1 day, 4 hours ago -
Windows 11 Insider Preview build 26200.5570 released to DEV
by
joep517
1 day, 18 hours ago -
Windows 11 Insider Preview build 26120.3941 (24H2) released to BETA
by
joep517
1 day, 20 hours ago -
Windows 11 Insider Preview Build 22635.5305 (23H2) released to BETA
by
joep517
1 day, 20 hours ago -
No April cumulative update for Win 11 23H2?
by
Peobody
8 hours, 3 minutes ago -
AugLoop.All (TEST Augmentation Loop MSIT)
by
LarryK
1 day, 20 hours ago -
Boot Sequence for Dell Optiplex 7070 Tower
by
Serge Carniol
2 days, 11 hours ago -
OTT Upgrade Windows 11 to 24H2 on Unsupported Hardware
by
bbearren
2 days, 15 hours ago -
Inetpub can be tricked
by
Susan Bradley
22 hours, 39 minutes ago -
How merge Outlook 2016 .pst file w/into newly created Outlook 2024 install .pst?
by
Tex265
1 day, 9 hours ago -
FBI 2024 Internet Crime Report
by
Alex5723
2 days, 19 hours ago -
Perplexity CEO says its browser will track everything users do online
by
Alex5723
4 hours, 4 minutes ago -
Login issues with Windows Hello
by
CWBillow
3 days, 6 hours ago -
How to get into a manual setup screen in 2024 Outlook classic?
by
Tex265
2 days, 17 hours ago -
Linux : ARMO rootkit “Curing”
by
Alex5723
3 days, 17 hours ago -
Employee monitoring app leaks 21 million screenshots in real time
by
Alex5723
3 days, 17 hours ago -
Google AI is now hallucinating idioms
by
Alex5723
3 days, 18 hours ago -
april update
by
69800
1 day, 22 hours ago -
Windows 11 Insider Preview build 27842 released to Canary
by
joep517
3 days, 19 hours ago -
Quick Fix for Slowing File Explorer
by
Drcard:))
3 days, 19 hours ago -
WuMgr not loading?
by
LHiggins
2 days, 15 hours ago -
Word crashes when accessing Help
by
CWBillow
5 hours, 19 minutes ago -
New Microsoft Nag — Danger! Danger! sign-in to your Microsoft Account
by
EricB
3 days, 19 hours ago -
Blank Inetpub folder
by
Susan Bradley
3 days, 16 hours ago -
Google : Extended Repair Program for Pixel 7a
by
Alex5723
4 days, 5 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.