473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Trying to open a saved report with a filter specification (A97)

MLH
Private Sub Command0_Click()
Dim MyReport As Report
MyReport.Name = "rptStateOfAffairs"
MyReport.Filter = "ClusterName = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenReport MyReport.Name
End Sub

Above code fails - Access doesn't like the 4th line. What change need
I make to open the report with desired filter spec?
Jun 19 '07 #1
3 1490
MLH wrote:
Private Sub Command0_Click()
Dim MyReport As Report
MyReport.Name = "rptStateOfAffairs"
MyReport.Filter = "ClusterName = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenReport MyReport.Name
End Sub

Above code fails - Access doesn't like the 4th line. What change need
I make to open the report with desired filter spec?
Why not
Dim MyReport As String
MyReport = "rptStateOfAffairs"
Docmd.OpenReport MyReport,,,"ClusterName = 'Auto Company, Inc'"

Btw, you are setting MyReport's filter, through the report isn't open
and then you are turning on Me's filteron to true, not the reports.

Also, you never set MyReport to an object.

So there are a variety of things that could go wrong.

Jun 19 '07 #2
On Mon, 18 Jun 2007 21:00:47 -0400, MLH wrote:
Private Sub Command0_Click()
Dim MyReport As Report
MyReport.Name = "rptStateOfAffairs"
MyReport.Filter = "ClusterName = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenReport MyReport.Name
End Sub

Above code fails - Access doesn't like the 4th line. What change need
I make to open the report with desired filter spec?
You wish to hard code the filter into this code?

Private Sub Command0_Click()
Dim stDocName as String
Dim stWhere as string
stDocName = "rptStateOfaffairs"
stWhere = "[ClusterName] = 'Auto Company, Inc'"

DoCmd.OpenReport stDocName, acViewPreview, , stWhere
End Sub.

Of course you can simplify the above to:

Private Sub Command0_Click()
DoCmd.OpenReport "rptStateOfAffairs", acViewPreview, , "[ClusterName]
= 'Auto Company, Inc'"
End Sub

Look up the OpenReport method in VBA help for the necessary arguments.
Cbange acViewPreview to acViewNormal to print without previewing.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 19 '07 #3
MLH
What was I thinkin'?
Thanks, Salad.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
Why not
Dim MyReport As String
MyReport = "rptStateOfAffairs"
Docmd.OpenReport MyReport,,,"ClusterName = 'Auto Company, Inc'"

Btw, you are setting MyReport's filter, through the report isn't open
and then you are turning on Me's filteron to true, not the reports.

Also, you never set MyReport to an object.

So there are a variety of things that could go wrong.
Jun 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: G.Gerard | last post by:
Hello I am setting the Order By property of a subreport on the On Open Event of the subreport and I am getting the following error: error number 2101 ( The setting you entered isn't valid...
0
by: Douglas Buchanan | last post by:
I cannot create a database. (A97) Not with *any* name I try! I get the following error: ====================== Microsoft Access ---------------------- The Database 'C:\Documents and...
9
by: MLH | last post by:
Trouble is, it doesn't happen every time. Yesterday, for example, it happened only once and not again afterward. Some days ago, a similar situation. Today, well - I tried 7 times straight to open...
12
by: Ron Weldy | last post by:
I have a test server runinng 2003/IIS 6 with a mixture of asp and asp.net files. On my workstation I have a share set up to the folder where the web files reside. I am just doing quick and dirty...
10
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the...
3
by: gmazza via AccessMonster.com | last post by:
Hi there, I am trying to run a report using a parameter for where the user chooses a month from a combo box. Then on the report, I want it to compare the month to a date field and choose only...
0
by: Kelii | last post by:
Evenlater, Yeah, I don't open the report in preview mode when I setup my recordsource, filters, or sorts. Before I give my solution, I would say that your code will be simpler if you drop the...
3
by: BarbaraB | last post by:
Is there anyway of returning the value of an option group (in access 2003) back to what it was before any entry was made? I frequenty find people are wishing to remove there answer but with an...
9
by: sparks | last post by:
Right now I had to build a report that allowed the people to check for gross outliers in their data input. short I am looking at 2.5* std dev + - anyway I used 2 dummy variables in the query the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.