473,952 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

MLH
Private Sub Command0_Click( )
Dim MyReport As Report
MyReport.Name = "rptStateOfAffa irs"
MyReport.Filter = "ClusterNam e = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenRepor t 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 1514
MLH wrote:
Private Sub Command0_Click( )
Dim MyReport As Report
MyReport.Name = "rptStateOfAffa irs"
MyReport.Filter = "ClusterNam e = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenRepor t 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 = "rptStateOfAffa irs"
Docmd.OpenRepor t MyReport,,,"Clu sterName = '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 = "rptStateOfAffa irs"
MyReport.Filter = "ClusterNam e = 'Auto Company, Inc'"
Me.FilterOn = True
DoCmd.OpenRepor t 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 = "rptStateOfaffa irs"
stWhere = "[ClusterName] = 'Auto Company, Inc'"

DoCmd.OpenRepor t stDocName, acViewPreview, , stWhere
End Sub.

Of course you can simplify the above to:

Private Sub Command0_Click( )
DoCmd.OpenRepor t "rptStateOfAffa irs", 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.
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx
>
Why not
Dim MyReport As String
MyReport = "rptStateOfAffa irs"
Docmd.OpenRepor t MyReport,,,"Clu sterName = '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
5782
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 for this property.) Oddly enough, event though I get this error , the Order By property settings
0
1187
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 Settings\db1.mdb' you tried to delete and replace is read-only and can't be deleted or replaced. Enter a different name for the new database.
9
1796
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 the report and each time, A97 shuts down. The seemingly hit 'n miss nature of the error is intriguing. All I've been able to determine is that if I allow the report to be opened from within code using this line... DoCmd.OpenReport...
12
3119
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 asp editing (like I used to be able to do with 2K/IIS5) where I use VS.NET, open an asp file, make changes, save and refresh my browser. Problem is that I get an Access is Denied error when I try to save the file and then the file gets wiped on...
10
2604
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 already existing query. I know I can copy the report and base it on another query but then I would have to make 10 extra reports. How can I use just one report for all of the queries? At the moment I use the button wizard in my forms to make buttons...
3
5736
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 those dates with the month chosen from the parameter form. Basically, its to see who's birthdays are coming up. So on the parameter form you choose November, so then I want the report to display all the kids who's birthdays are in November. Any help...
0
1592
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 "Sort" button and simply include the sorts in the primary window rather than a window in dialog mode. For example, I use 5 sorts in my preview screen, the first sort is always enabled, the second sort only becomes enabled if the first is not null...
3
5999
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 option group it seems as if once you have made a choice, although you can change the choice, there is no way of returning it to its original state of having nothing selected. I know I can do this with a combo box by simply deleting the entry but I was...
9
1854
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 report is tied to. start date and end date. This pops up an input box for these values and they put in 11/01/08 and 11/31/08 and it runs the report showing the outliers. I watched and everyone is looking at month not date Now I was thinking...
0
10188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10004
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11218
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11388
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8293
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3569
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.