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

What are the between statement parameters in a Query? Dropping the high-end records.

133 100+
I have a between statement within a query for a date range as follows:

Expand|Select|Wrap|Line Numbers
  1. between #6/1/2010# and 6/30/2010#
  2.  

What are the between statement parameters rules? I am dropping the records on the high-end of the criteria, 6/30/2010. The data contains time stamp information, would this have an effect of the results and can how can it be corrected without changing the date range to the first day of the next month?

Would appreciate any assistance.
Sep 20 '10 #1
2 1443
OldBirdman
675 512MB
6/30/2010# should have a '#' in front of it, and probably does in the actual code.
With no time, #6/30/2010# is #6/30/2010 12:00:00AM#, or midnight of the morning of June 30. Therefore, all times on June 30 after midnight, which are probably all of them, are not between the two dates. You need to either add one to the upper limit date, OR test DateValue([your date]) Between between #6/1/2010# and #6/30/2010#
Sep 20 '10 #2
dowlingm815
133 100+
Thank you for your response. The date was converted correctly with the following statement.

Expand|Select|Wrap|Line Numbers
  1. Creation Date2: DateValue([Creation Date])
  2.  
When the date range is selected as a static value as:

Expand|Select|Wrap|Line Numbers
  1. Between #6/1/2010# And #6/30/2010#
  2.  
The query selects the proper date ranges. However, when a dynamic value is selected through a form value, no results are yielded.

Expand|Select|Wrap|Line Numbers
  1. Between [Forms]![F_Waiver_Yr]![txb_date_start] And [Forms]![F_Waiver_Yr]![txb_date_end]
  2.  
Since it didn't execute properly in the query i used VBA to run a SQL statement, where the data gets processed correctly. the code is as follows:


Expand|Select|Wrap|Line Numbers
  1. Private Sub Extract_POScreenAmt()
  2.  
  3. On Error GoTo Err_Hndlr
  4.  
  5. '**********************************************
  6. Dim dbs As Database
  7. Dim strSQL As String
  8. Dim strQueryName As String
  9. Dim qryDef As QueryDef
  10.  
  11. 'set variable values
  12. Set dbs = CurrentDb
  13. strQueryName = "sql_Extract_POScreenAmt"
  14.  
  15. 'Delete old query first - we want fresh data!
  16. dbs.QueryDefs.Delete strQueryName
  17.  
  18. 'Notice below how we inserted the variable as a parameter value - Visual Basic will evaluate strMonth and insert the value for us.
  19.  
  20.  
  21. strSQL = "SELECT POCompletedScreen.[PO #], POCompletedScreen.[PO Total], DateValue([Creation Date]) AS [Creation Date2] " & _
  22.             "FROM POCompletedScreen " & _
  23.             "GROUP BY " & _
  24.                 "POCompletedScreen.[PO #], " & _
  25.                 "POCompletedScreen.[PO Total], " & _
  26.                 "DateValue([Creation Date]) " & _
  27.             "HAVING DateValue([Creation Date]) " & _
  28.             "Between #" & [Forms]![F_Waiver_Yr]![txb_date_start] & _
  29.                     "# And #" & [Forms]![F_Waiver_Yr]![txb_date_end] & "# " & _
  30.             "ORDER BY POCompletedScreen.[PO #];"
  31.  
  32.  
  33. ' "HAVING PRApprovalHistory.PR_Date " & _
  34. '           "Between #" & [Forms]!F_MktPlace_DataRun![txb_MktPlace_Start_Date] & _
  35. '           "# And #" & [Forms]!F_MktPlace_DataRun![txb_MktPlace_End_Date] & "# " &
  36.  
  37.  
  38.  
  39. 'Create query definition
  40. Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)
  41.  
  42.  
  43.  
  44. Extract_POScreenAmt_Exit:
  45.   Exit Sub
  46.  
  47.  
  48. Err_Hndlr:
  49.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Extract_POScreenAmt()"
  50. End Sub
  51.  
  52.  
Sep 21 '10 #3

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

Similar topics

7
by: What-a-Tool | last post by:
Have no problem getting my select queries to work using this method: strSQL = "SELECT tblUI.IPAdd FROM tblUI WHERE (tblUI.IPAdd =?)" arSPrm = Array(strRemHst) Set rst = cmd.Execute(,arSPrm)...
1
by: Dragan | last post by:
How can I adjust the vertical size of query and save it? In older versions of Access XP, it is enough to make position height by mouse-drag and save. When I reopen the , height changes remain...
1
by: Rose | last post by:
I have an ACCESS 2000 database and I have a table with a field setup as a MEMO. I am trying to run a query and append the MEMO field to another table - everytime I run the query - it drops data -...
1
by: Brian Jorgenson | last post by:
Is it possible to add a If-then statement in a query? For example, If field B is greater then field A, then field B = something else. I am creating a class schedule. My class size's are 5 people...
2
by: k7i5t3n | last post by:
I have two tables I'm using in a query. I have pulled several fields from 'tblEmployeeList' and need to pull a Yes/No field 'FileStampNumber' from the table 'tblFileStamps'. However, I need to...
0
by: 1harsh789 | last post by:
Hi, Can anyone please tell me about What is ODBC Query timeout error? And How to resolve this issue. Thanks.
5
JodiPhillips
by: JodiPhillips | last post by:
Hello again, I'm having a lot of trouble understanding the interaction between code and SQL. I have several queries that drive various reports and forms in my db and each query contains a common...
1
by: Darknight850 | last post by:
Hello Every One, I am having a problem with an IIF statement in a query I have going. Before I start I would like to say I have had some problems in the past with supplying enough information, if...
3
by: mzahid | last post by:
I have 3 tables student(s_id,s_name),course(c_id,c_name) and student_course(s_id(FK),c_id(FK)). I would Like to select those students Name who have enrolled more then and equal to 3 courses. What...
3
by: yappy77 | last post by:
The following is my IIF statement in my query: BuyerName:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.