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 4275
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,556
Expert Mod 16PB
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.OpenReport()). 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,556
Expert Mod 16PB
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,556
Expert Mod 16PB
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...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |