473,385 Members | 1,356 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,385 software developers and data experts.

Re: Is there a way to open a report in preview or report mode andhave it be invisible?

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 and not empty string.

Back to your question, the solution I use is as follows:
1. Setup a bunch of variables in your code that identify the pieces of
the recordsource, filter, or sort criteria that you want to modify
(e.g., varCategory, varType, varLocation); I use variant here b/c I
can get null strings
2. Set these variables equal to the values chosen by the user
3. Build a SQL string that can accomodate your recordsource, filter,
or sort under the variety of circumstances imposed by the user
4. Open the report
5. Set the recordsource, filter, or sort equal to your SQL string

Here's an example:
This is in the cmdPreviewReport object:
'Open inventory count sheet report with proper filter and sequence
DoCmd.OpenReport "rptInventory", acPreview
Reports!rptInventory.Filter = FilterSequence
Reports!rptInventory.FilterOn = True
Reports!rptInventory.OrderBy = SortSequence
Reports!rptInventory.OrderByOn = True

This is the Function FilterSequence:
Private Function FilterSequence()
On Error GoTo Error_Handler

Dim varClass As Variant
Dim varCategory As Variant
Dim varType As Variant
Dim varLocation As Variant

Dim strClassFltr As String
Dim strCategoryFltr As String
Dim strTypeFltr As String
Dim strLocationFltr As String

'Check to see if any filters exist
If Me.fraPrintOptions = 1 Then
'No filters exist, exit sub with no filter
FilterSequence = "(SortZero<>0)"
Exit Function
End If

'Set variables equal to values in filtering combo boxes
varClass = Me.cboSelectClass
varCategory = Me.cboSelectItemCategory
varType = Me.cboSelectItemType
varLocation = Me.cboSelectItemLocation

'Compile Class, Category, Type, and Location portions
'of the filter
'Note: company location portion of filter is handled
'within the various build queries as criteria; this was
'done to improve the speed of the final source query
If varClass = "" Or varClass = "<all>" Then
strClassFltr = ""
Else
strClassFltr = "((qryInventoryReportBuild2.Class = '" &
varClass & "')) AND "
End If

If varCategory = "" Or varCategory = "<all>" Then
strCategoryFltr = ""
Else
strCategoryFltr = "((qryInventoryReportBuild2.Item_Category =
'" & varCategory & "')) AND "
End If

If varType = "" Or varType = "<all>" Then
strTypeFltr = ""
Else
strTypeFltr = "((qryInventoryReportBuild2.Item_Type = '" &
varType & "')) AND "
End If

If varLocation = "" Or varLocation = "<all>" Then
strLocationFltr = ""
Else
strLocationFltr = "((qryInventoryReportBuild2.Item_Location =
'" & varLocation & "')) AND "
End If

FilterSequence = "(" & strClassFltr & strCategoryFltr &
strTypeFltr & strLocationFltr & _
"SortZero <0)"

Exit_Procedure:
On Error Resume Next
Exit Function
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Function

I hope something like this works for you.

Kelii
Jun 27 '08 #1
0 1543

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

Similar topics

1
by: Eager-Learner | last post by:
Through window.open or window.showmodaldialog, I want to open a word or excel document in Print Preview mode. Bcos I don't want the user to make any changes or save it but the user can ONLY VIEW OR...
4
by: Steve Jorgensen | last post by:
Hi all, This is actually not an issue of mine, but one a friend of mine told me about that I was able to confirm. Let's say you want a highly customizable report, so you want to be able to do...
2
by: Henry J. Murphy | last post by:
I have a report that has been running without incident for 2 years. Today all the labels on the report no longer print. All are Visible in their individual property pages. Labels on all other...
2
by: Wolfgang | last post by:
Hi, I need to timestamp printed records with the printing date. According to the customer's requests the report must be opened in preview-mode and the user clicks on the printer button if he...
1
by: solar | last post by:
In order to check for figures i want to make a function that opens and closes a report in a succcession depending on the option values chosen.Instead of clicking on the option group called Houses,...
4
by: Richard Sherratt | last post by:
Access 97 and SQL Server 2000. Reports in this system are driven from a parameter form. Parameters are used to make a WHERE clause. If no parameters are selected, strWhere is a zero length...
4
by: Gary | last post by:
Hello, I'm hoping someone can shed some light on why my report does not output the same results as shown in preview mode, which is to move the position of a check box based on a field value (see...
8
by: paii, Ron | last post by:
I have a report that is opened in preview mode, the users can view it then send it to a printer. I want to; in the same command display a dialog box with "Yes/No" to confirm the next step. How do I...
0
by: Kelii | last post by:
evenlater, ok, so i think the thing that we have to get our heads around here is that there is no way to identify the selected fields in a recordsource without first opening the report. so, i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.