473,396 Members | 1,866 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,396 software developers and data experts.

Retrieving Data between 2 dates

4
I have a data base that is used for billing. I have a form called a report selector form. Below is the code used to create the report from the user inputs on the form. What I want to do is add a way for the users to input dates and when they push the intake button they get all the date between the two dates the user/s input.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdIntake_Click()
  2.     Dim strCountyName As String
  3.     Dim strAgencyStatus As String
  4.     Dim strReferalSource As String
  5.     Dim StrServices As String
  6.     Dim StrPOStatus As String
  7.     Dim strFilter As String
  8.     Dim strStaff As String
  9.     Dim strReferalDate As String
  10.  
  11. ' HAVE the report auto open for user
  12. If SysCmd(acSysCmdGetObjectState, acReport, "rptIntakeBilling") <> acObjStateOpen Then
  13.     DoCmd.OpenReport "rptIntakeBilling", acViewPreview
  14. End If
  15. ' Build criteria string for CountyName field
  16.     If IsNull(Me.cboCountyName.Value) Then
  17.         strCountyName = "Like '*'"
  18.     Else
  19.         strCountyName = "='" & Me.cboCountyName.Value & "'"
  20.     End If
  21. ' Build criteria string for AgencyStatus field
  22.     If IsNull(Me.cboAgencyStatus.Value) Then
  23.         strAgencyStatus = "Like '*'"
  24.     Else
  25.         strAgencyStatus = "='" & Me.cboAgencyStatus.Value & "'"
  26.     End If
  27. ' Build criteria string for ReferalSource field
  28.     If IsNull(Me.cboReferalSource.Value) Then
  29.         strReferalSource = "Like '*'"
  30.     Else
  31.         strReferalSource = "='" & Me.cboReferalSource.Value & "'"
  32.     End If
  33. ' Build criteria string for Services field
  34.     If IsNull(Me.cboServices.Value) Then
  35.         StrServices = "Like '*'"
  36.     Else
  37.         StrServices = "='" & Me.cboServices.Value & "'"
  38.     End If
  39. ' Build criteria string for POStatus field
  40.     If IsNull(Me.cboPOStatus.Value) Then
  41.         StrPOStatus = "Like '*'"
  42.     Else
  43.         StrPOStatus = "='" & Me.cboPOStatus.Value & "'"
  44.     End If
  45. ' Build criteria string for POStaff field
  46.     If IsNull(Me.cboStaff.Value) Then
  47.         strStaff = "Like '*'"
  48.     Else
  49.         strStaff = "='" & Me.cboStaff.Value & "'"
  50.     End If
  51.  
  52. ' Combine criteria strings into a WHERE clause for the filter
  53.     strFilter = "[CountyName] " & strCountyName & " AND [AgencyStatus] " & strAgencyStatus & " AND [RefCode] " & strReferalSource & " AND [Service] " & StrServices & " AND [POStatus] " & StrPOStatus & " AND [Staff Initials] " & strStaff
  54. ' Apply the filter and switch it on
  55.     With Reports![rptIntakeBilling]
  56.         .Filter = strFilter
  57.         .FilterOn = True
  58.         '.txtIntakeReportHeader.Value = _
  59.         '"INTAKE REPORT: " & vbCrLf & "Referal Source: " & Me.cboReferalSource.Value _
  60.         '& vbCrLf & "County: " & Me.cboCountyName.Value _
  61.         '& vbCrLf & "Staff: " & Me.cboStaff.Value
  62.     End With
  63. End Sub
I am havnig a heck of a time trying to get the syntax correct I want to use the ReferalDate field. Which is the only short date in the table used to retrieve all the other data. Any help would be appriciated.



Thanks Falroc
Oct 13 '08 #1
2 2205
Add 2 text boxes on your form for beginning date and ending date. Then in your code, add coding something like "ReferralDate BETWEEN #" & Forms!frmReportSelector!txtBeginningDate & "# AND #" & Forms!frmReportSelector!txtEndingDate & "#".

Did that help???
Oct 13 '08 #2
falroc
4
Add 2 text boxes on your form for beginning date and ending date. Then in your code, add coding something like "ReferralDate BETWEEN #" & Forms!frmReportSelector!txtBeginningDate & "# AND #" & Forms!frmReportSelector!txtEndingDate & "#".

Did that help???
First of all thank you so much for answering. I am a complete noob. The syntax looks like it will work but I haven't got a clue how to put it into the module. The module I attached was written by someone else and I have mangaged to reverse engineer most of it. But, now I am at a complete loss. I have been trying to teach myself VBA. I am under the gun now as my bosses want to me to have it ready by next week. This is the last thing I have to do but it is really causing me some frustration.
Oct 14 '08 #3

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

Similar topics

17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
2
by: AndyJ | last post by:
Hi and thanks in advance for any assistance recieved, There is most likely a simple solution to this as usual... I am trying to access data from an Excell worksheet using ADO. The problem is...
1
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
15
by: nkechifesie | last post by:
I am trying to retrieve dates from the database using a range. This is the Code I am using which is giving me an error Public AdVehDecp As ADODB.Connection Public RsQry As ADODB.Recordset...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
2
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hi and Hello. Good Day. I have a problem in retrieving time in database. I have Table name "SAMPLE" and have field name "DATES" DATES -------------------------------------| 5/9/2008...
2
by: Patrick Pirtle | last post by:
Having programmed for a number of years with VB6 (but very little database stuff), I'm trying to learn Visual Studio, but am just about at the end of my rope as far as wrapping my mind around...
0
by: chanlichin | last post by:
Select Case (cbMonth.Text) Case "January" Dates = "1" Case "February" Dates = "2" Case "March"
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
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...
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
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
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...

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.