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

Select multiple date fields from one table

I am trying to create a report by selecting three date fields from one
table with records between a start date and end date. I have tried to
adapt one of Allen Browne's scripts as follows but it gives me records
outside my date criteria - I guess my strSelect is wrong! I tried
strSelect = * but that didn't work either.

Private Sub CmndOK_Click()
Dim strReport As String 'Name of report to open.
Dim strWhere As String 'Where condition for OpenReport.
Dim strSelect As String
Dim strFrom As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strReport = "TermDeposits"

strSelect =
"Termdeposits.TermDeposit1MaturityDate,Termdeposit s.TermDeposit2MaturityDate,Termdeposits.TermDeposi t3MaturityDate"

strWhere = strSelect & " Between " &
Format(Me.txtStartDate, conDateFormat) & " And " &
Format(Me.txtEndDate, conDateFormat)

' Debug.Print strWhere 'For debugging
purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub

Nov 13 '05 #1
5 3058
Try this line:

strWhere = "(TermDeposit1MaturityDate Between " & Format(Me.txtStartDate,
conDateFormat) & " And " & Format(Me.txtEndDate, conDateFormat) & ") OR
(TermDeposit2MaturityDate Between " & Format(Me.txtStartDate, conDateFormat)
& " And " & Format(Me.txtEndDate, conDateFormat) & ") OR
(TermDeposit3MaturityDate Between " & Format(Me.txtStartDate, conDateFormat)
& " And " & Format(Me.txtEndDate, conDateFormat) & ")"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"QBCM" <le*****@qbcm.com-dot-au.no-spam.invalid> wrote in message
news:l8********************@giganews.com...
I am trying to create a report by selecting three date fields from one
table with records between a start date and end date. I have tried to
adapt one of Allen Browne's scripts as follows but it gives me records
outside my date criteria - I guess my strSelect is wrong! I tried
strSelect = * but that didn't work either.

Private Sub CmndOK_Click()
Dim strReport As String 'Name of report to open.
Dim strWhere As String 'Where condition for OpenReport.
Dim strSelect As String
Dim strFrom As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strReport = "TermDeposits"

strSelect =
"Termdeposits.TermDeposit1MaturityDate,Termdeposit s.TermDeposit2MaturityDate,Termdeposits.TermDeposi t3MaturityDate"

strWhere = strSelect & " Between " &
Format(Me.txtStartDate, conDateFormat) & " And " &
Format(Me.txtEndDate, conDateFormat)

' Debug.Print strWhere 'For debugging
purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub

Nov 13 '05 #2
That's probably an irritating enough problem to create a special
function to put all your dates in US Format... would be really nice if
Access would just apply the OS setting...

Nov 13 '05 #3
Hi Allen
Many thanks for replying I have laboured for some time on this! When
I try your WHERE clause I get an error - Compile error Expected: End
of statement - and it highlights the the first OR

Thanks for your assistance

Nov 13 '05 #4
To see an example of what you need to get, create a query into this table.

Drag the 3 date fields into the grid.
In the criteria below each, enter a date range, e.g.:
Between #1/1/2005# And #2/1/2005#
Be sure to use 3 different rows of the criteria.

Now switch to SQL View (View menu.)
Look at the WHERE clause in the query.
You need to create a string that ends up like that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"QBCM" <le*****@qbcm.com-dot-au.no-spam.invalid> wrote in message
news:ef********************@giganews.com...
Hi Allen
Many thanks for replying I have laboured for some time on this! When
I try your WHERE clause I get an error - Compile error Expected: End
of statement - and it highlights the the first OR

Thanks for your assistance

Nov 13 '05 #5
Hi Allen

It works fine now - must have been a typo on my part!

Nov 13 '05 #6

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

Similar topics

3
by: Ker | last post by:
I have a query that works great. It gives me the min for multiple fields. Within this query, I also need to get the max of some fields too. I currently have output of Date Name ...
9
by: Kelvin | last post by:
Okay so this is baking my noodle. I want to select all the attritbutes/fields from a table but then to excluded any row in which a single attributes data has been duplicated. I.E. Here's my...
1
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet,...
0
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the...
13
by: ricky.agrawal | last post by:
I'm really not sure how to go about this in Access. What I've created is a table for each location. Those tables are identical in format but different in information. The tables are named after...
2
by: chrisale | last post by:
Hi All, I've been racking my brain trying to figure out some sort of Sub-Select mySQL statement that will create a result with multiple rows of averaged values over a years time. What I have...
4
by: Dave White | last post by:
Hello Everyone, I have created two tables to track my students' lessons. Each student is responsible for most, but not all. of the lessons. I've tried a junction table but I can't figure out...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
4
by: scalda34 | last post by:
This in Access 2003. Pardon me if this is in the wrong spot, but I hoped someone could help. I have a table with multiple records that have a text represented date field. The date is in a format...
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?
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
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.