473,406 Members | 2,894 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,406 software developers and data experts.

Sort Report on Fly between dates

147 100+
I am trying to sort a report on the fly with dates please let me know whow I can get the following code to work, I know I have it configured incorrectly.
Thanks
Expand|Select|Wrap|Line Numbers
  1. ElseIf TypeOf c Is Access.TextBox Then
  2. strSQL = strSQL & "([" & c.Tag & "] BETWEEN  #" & c & "# And Forms![frmParkingFilter]![EndingDate])  And "
Feb 18 '09 #1
7 1762
DAHMB
147 100+
Opps that should only have two lines sorry about that I am trying to learn to use the site properly. Thanks
Dan
Feb 18 '09 #2
NeoPa
32,556 Expert Mod 16PB
Dan, there's not even a reference to your report in the code. From the look of it, this is code to build up a SQL string.

Please explain your question more clearly, using names of objects where appropriate. An explanation of what (& why) you are trying to do would help too.

There are various techniques to use, knowing which is appropriate for you, requires some understanding of your situation.
Feb 18 '09 #3
DAHMB
147 100+
Thanks but I got it it goes like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub FilterParking_Click()
  2.   Dim strSQL As String, intCounter As Integer
  3.   Dim c As Access.Control
  4.   Dim stFilter As String
  5.   stFilter = ("DateReceived Is Null")
  6.   For intCounter = 1 To 3
  7.     If Me("Filter" & intCounter) <> "" Then
  8.     Set c = Me("Filter" & intCounter)
  9.       If TypeOf c Is Access.ComboBox Then
  10.         strSQL = strSQL & "[" & c.Tag & "] " & " = " & Chr(34) & c & Chr(34) & " And "
  11.       ElseIf TypeOf c Is Access.TextBox Then
  12.         strSQL = strSQL & "([" & c.Tag & "] BETWEEN  #" & c & "# And #" & [EndingDate] & "#) And "
  13.       ElseIf TypeOf c Is Access.CheckBox Then
  14.         If c.Value = True Then
  15.           strSQL = strSQL & stFilter & " And "
  16.         End If
  17.       End If
  18.     End If
  19.   Next
  20.   If strSQL <> "" Then
  21.     strSQL = Left(strSQL, (Len(strSQL) - 5))
  22.     Reports!rptParkingTickets.Filter = strSQL
  23.     Reports!rptParkingTickets.FilterOn = True
  24.   End If
Feb 18 '09 #4
NeoPa
32,556 Expert Mod 16PB
I guess this means you were never talking about sorting the report at all, but rather about applying a filter?
Feb 18 '09 #5
Stewart Ross
2,545 Expert Mod 2GB
Hi. Glad you got this sorted out, but as NeoPa pointed out there was a mismatch between what you told us and what you really wanted - this is not about sorting a report on the fly, it is about filtering the report for tickets issued between certain dates. A crucial difference.

It is also simpler in my opinion just to filter the report when you open it from DoCmd.OpenReport. You can supply a WHERE clause (without the WHERE keyword) as one of the parameters to the OpenReport method.

An extract from the MS Help entry for OpenReport is shown below:

expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

WhereCondition Optional Variant. A string expression that's a valid SQL WHERE clause without the word WHERE.
-Stewart
Feb 18 '09 #6
DAHMB
147 100+
Yes but with the code above I can open the report and then filter it in various ways without closing and reopening it using diferent queries and/or command buttons.
Feb 20 '09 #7
NeoPa
32,556 Expert Mod 16PB
There certainly are occasions where you may well want to change the filtering on the fly Dan. It doesn't seem to come up much, but depending on requirements, it can do.

I think Stewart's main point though, was that a fair amount of time could be saved if you went to the trouble of checking your posts a bit more carefully before submitting them.

I don't think that's too unreasonable an expectation in the circumstances.
Feb 20 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
5
by: Jim Fox | last post by:
I have a report that I created that has no data, just boxes, lines and one date field not tied to anything. Basically this report will just print pages according to the dates you entered. Then...
5
by: Michelle | last post by:
Hi all I have a report which displays staff absences. An absence record has a start and end date and the type of absence, ie sickness, annual leave. I have created a form which allows the...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: Mike Cooper | last post by:
Hi everyone, This is a tough one. I have a database full of solicitations, identifying a customer and recording initial call, first followup, second followup, etc. My boss want to be able to...
1
by: Brad | last post by:
Thanks for taking the time to read my question. I have a table of data that has Date, Data and Category. I need to show, in a report, each Categories Data by Date. The Date has to be it's own...
5
by: sara | last post by:
I have reports that run from a form where the user can choose a date range, or they run automatically for a week in the "Weekly Reports" option. I created 2 queries and 2 reports - one query...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
1
by: Dale | last post by:
Access 2003 I am trying to figure out how to develop a report that will display students in 1st column, dates across the top, and "P" or "A" for the data. I have a crosstab that displays what I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
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,...

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.