I am trying to pass the parameters when I open a report but the report opens with all records instead of being filtered. - Dim strReport As String
-
Dim strDateField As String
-
Dim startDate As String
-
Dim endDate As String
-
Dim strWhere As String
-
Dim lngView As Long
-
Const strcJetDate = "\#mm\/dd\/yyyy\#"
-
-
strDateField=[SubmitDate]
-
Select Case Me!ReportToPrint
-
-
Case 3
-
If IsNull(Forms![Reports Dialog]!SelectCategory) Then
-
DoCmd.OpenReport "Category Reports", PrintMode
-
Else
-
-
If SelectCategory.ListIndex = 0 Then
-
startDate = Date - 2
-
MsgBox startDate
-
endDate = Date
-
-
-
End If
-
MsgBox strDateField
-
strWhere = "(" & strDateField & " < " & Format(startDate, strcJetDate) & ")"
-
strWhere = strWhere & "(" & strDateField & " < " & endDate & ")"
-
Debug.Print strWhere
-
DoCmd.OpenReport "Category Reports", PrintMode, , strWhere
-
End If
-
End Select
-
DoCmd.Close acForm, "Reports Dialog"
6 4301 FishVal 2,653
Recognized Expert Specialist
Hello, xraive.
Your code is very messy. - startDate and endDate are declared as String type variables. However you assign Date type values to them. Though VBA could silently convert type to an appropriate one, the resulting value could be what you are not expecting for. To say nothing about that Format() function can't format String type value as Date type value.
- Even though you've not attempted to format properly endDate variable value while incorporating it to strWhere.
- There is no logical operator between two conditions in strWhere.
- Having
Debug.Print strWhere
you might pay attention to the value of strWhere you try to pass to the report. - Just out of curiosity - what is the reason to name vaiables startDate and endDate this way. Do you think it is something about Hungarian notation?
Kind regards,
Fish.
NeoPa 32,573
Recognized Expert Moderator MVP
XRaive,
Please remember to use the CODE tags rather than the QUOTE tags for your code.
Also, it is courteous to indent your code properly before posting if you expect people to read through it. Messy code is no help to you, and is likely to irritate those you are hoping will help you.
If Fish's comments don't help you to your solution (I expect they will in fact) then I suggest you get clear which line of code is causing your problem (which of the two calls on lines #14 & #28) and then look through the Help documentation for the call (DoCmd.OpenRepor t()). You will find everything you need there to explain your problem.
I apologize for the messy code guys and for not using the code tags. I will in the future.
Thank you,
NeoPa 32,573
Recognized Expert Moderator MVP
Did you find that sorted your problem?
PS. Some (hopefully) helpful info on using the CODE tags (I meant to post before for you) :
Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).
Thank you Neopa I will follow your instructions.
In regards to the problem I was having I decided to create hidden text fields that store date criteria on the form. I changed the query to refrence those two date fields on the form when running the report. This way I removed the need to store the date values in my code.
Thank you,
Rezene A.
NeoPa 32,573
Recognized Expert Moderator MVP
That sounds good. As long as your problem is behind you :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: CSDunn |
last post by:
Hello,
I have a situation with MS Access 2000 in which I need to display report
data in spreadsheet orientation (much like a datasheet view for a form). If
you think of the report in terms of what a spreadsheet might show, the
column names will actually be dynamic, based on data from a SQL Server 2000
database. The row data will also come from the same database. So in this
case, I will have a main report and a subreport. I've already tried...
|
by: Ryan Hubbard |
last post by:
Is it possible to get the recordset from an open query window? So you
run the query. The window is open. Can vba retrieve this data?
|
by: Mike Conklin |
last post by:
This one really has me going. Probably something silly. I'm using
dcount for a report to determine the number of different types of
tests proctored in a semester.
My report is based on a parameter query which is the recordsource for
the report. The parameter is <=. The query returns the
correct amounts upto the date entered (no need for "between" dates
here).
There are 8 textboxes with dcounts; 2 other boxes Sum some of these
|
by: lauren quantrell |
last post by:
When I open an Access form I can have no recordset specified, then in
the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColumn = 22)"
Me.recordsource = "dbo.sproc123"
But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.
I have worked around this by opening reports to a bogus recordsource
|
by: Randy Yates |
last post by:
When I try
fprintf(file, "Report of File %s\n", sMF->fileName);
I get a core dump. This works fine if fprintf is changed to
sprintf and a string buffer used instead as the first
parameter.
It looks like the standard descriptors are not really open.
| |
by: Dean Sabella |
last post by:
Hi,
I was trying to run a crystal report in the .net sample application
given at:
http://support.crystaldecisions.com/communityCS/FilesAndUpdates/
cppnet_win_subreport_basic.exe.asp
(I've reproduced the relevant file below.)
|
by: Henry |
last post by:
I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that
uses MS Access 2000 as its database. I can export reports that have no
linked sub reports for printing. However, I'm unable to export reports
that have linked subreports. I receive (a "Missing parameter field
current value") on the following statement:
Me.crReportDocument.Export()
The main report requires 4 parameters. The linked reports do not
require any...
|
by: mo |
last post by:
I have an application that uses Reporting Services. When the user
chooses to print a report, they are taken to a window that allows them
to fill in parameters for the report. They then click a button to
either export to PDF or to EXCEL. Once the report is generated, the
byte array containing the data is put into session and an aspx page is
loaded into a hidded iframe that "prints" the report (using the byte
array from session) causing...
|
by: Steve_Black |
last post by:
Hello,
I'm toying with the idea of loading a MenuStrip (VB.Net 2005)
dynamically based on who is logged into my system. Every user has
different security settings and I want to customize the main menu
instead of showing all possible options and only enabling/disabling
certain ones.
I have a table that stores the menu item name, parent item (if
applicable), display order, etc. so that I can dynamically load my
|
by: kamboj.shalabh |
last post by:
Hi to all,
Well, I am working on dotnet 2005 with crystal reports 10 and backend
as sql server.
I am facing a problem while loading a report.
Actually the issue is, when I load report it takes huge time to load a
report whether it is a 1 page report or thousands page report.
We have migrated the project from VB to VB.NET, in VB its working fine
because in that report is loaded page by page but in VB.NET whole
report is loaded in one go.
|
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...
| |
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,...
|
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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |