473,406 Members | 2,867 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.

Return All Records

How do I write the following expression so if I click through the two parameter
dialogs I get all records?

Between [Enter Start Date] And [Enter End Date]

Thanks!

Melissa
Nov 13 '05 #1
6 1811
"Melissa" <mk****@Earthlink.net> wrote in message
news:mg***************@newsread3.news.atl.earthlin k.net...
How do I write the following expression so if I click through the two parameter dialogs I get all records?

Between [Enter Start Date] And [Enter End Date]

in sql:

where
(someDate >= [Enter Start Date] or [Enter Start Date] Is Null)
and
(someDate <= [Enter End Date] or [Enter End Date] Is Null)
Nov 13 '05 #2
I just tested this, it worked.

Between Nz([Enter Start Date], DMin("[DateFieldName]", "[TableName]")) And
Nz([Enter End Date], DMax("[DateFieldName]", "[TableName]"))

--
Wayne Morgan
MS Access MVP
"Melissa" <mk****@Earthlink.net> wrote in message
news:mg***************@newsread3.news.atl.earthlin k.net...
How do I write the following expression so if I click through the two parameter dialogs I get all records?

Between [Enter Start Date] And [Enter End Date]

Thanks!

Melissa

Nov 13 '05 #3
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:s9***************@newssvr24.news.prodigy.com. ..
I just tested this, it worked.

Between Nz([Enter Start Date], DMin("[DateFieldName]", "[TableName]")) And
Nz([Enter End Date], DMax("[DateFieldName]", "[TableName]"))


it might work but it's an extremely inefficient way to do it - you are
forcing possibly two extra table scans for no reason. Unless the Jet
optimizer is smarter than I think :)
Nov 13 '05 #4
Melissa wrote:
How do I write the following expression so if I click through the two parameter
dialogs I get all records?

Between [Enter Start Date] And [Enter End Date]

Thanks!

Melissa


Knowing me, I'd probably create a form and scrap your parameter method.
I'd have a form with 2 date fields (from and to), a Select command
button and a Cancel command button. In the double click of each date
field I would call/present a calendar to ease data entry use. The dates
are nicely formated, may have an input mask on the form. If Cancel is
pressed, action stops. If Select is pressed write some code. Ex:

Dim strWhere As String
If Not IsNUll(Me.From) Then
strWhere = "DateField >=#" & Me.From & "# And "
Endif
If Not IsNUll(Me.To) Then
strWhere = "DateField <=#" & Me.To & "# And "
Endif
'remove AND at end of filter string
If strWhere > "" Then
strWhere = Left(strWHere,Len(strWhere)-5)
Endif

Then I'd call a form (datasheet perhaps) with your query with the
strWHere as the filter. Plus your form could add other filter parts and
you simply concatenate them to your string.

This is more powerful since you can select all records between a date,
all records if the filter is blank, all records greater/equal than the
from date, or all records less/equal the to date.

But that's my preference. Others have provided other options.

Nov 13 '05 #5
You are correct, I prefer your method.

--
Wayne Morgan
MS Access MVP
"John Winterbottom" <as******@hotmail.com> wrote in message
news:2h************@uni-berlin.de...
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:s9***************@newssvr24.news.prodigy.com. ..
I just tested this, it worked.

Between Nz([Enter Start Date], DMin("[DateFieldName]", "[TableName]")) And Nz([Enter End Date], DMax("[DateFieldName]", "[TableName]"))


it might work but it's an extremely inefficient way to do it - you are
forcing possibly two extra table scans for no reason. Unless the Jet
optimizer is smarter than I think :)

Nov 13 '05 #6
Ok, I sorted through what you have. It relies on True being anything but
zero. Nice.

--
Wayne Morgan
MS Access MVP
Nov 13 '05 #7

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

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
4
by: Ted | last post by:
Here's what I'm trying to do: I have a table, which I don't have administration over, with 4 interestingfields: RecordCount - an auto incrementing primary key CardNumber - integer CompanyID -...
3
by: Lance | last post by:
Hi, I used sp_addlinkedserver to link to a remote server through ODBC. When I execute select count(*) from LinkSrv.SI.DBO.SIHeader in SQL Query Analyzer. It returns 13705 records. But when I...
6
by: Toucan | last post by:
i need to retrieve the most recent timestamped records with unique names (see working query below) what i'm having trouble with is returning the next-most-recent records (records w/ id 1 and 3...
5
by: Petr Bravenec | last post by:
I have found that when I use the RETURN NEXT command in recursive function, not all records are returned. The only records I can obtain from function are records from the highest level of...
2
by: M.Stanley | last post by:
Hi, I have a problem..I'm doing a specific query where I'm joining fields from a table with appednded data (there are duplicate records, except for the date/time), and another query. I want the...
1
by: Jeff | last post by:
Hi I need to construct a SQL statement to return n records immediately following a specific date/time, but in descending order by date/time. Using TOP always gets n records immediately before...
6
by: John | last post by:
I've got a single table I need to query to return records that have no "related records." Table dataset example: 1. John, Biology 2. Dave, Math 3. Susan, Biology 4. Betty, Sociology The...
66
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if...
1
by: tjm0713 | last post by:
Not sure this can be done but here is my current situation. I have a table containing millions of records. Each record has 28 fields. One of the fields I am trying to return the single record for...
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: 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: 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
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
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...
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.