473,804 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving Data between 2 dates

4 New Member
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 2229
EManning
13 New Member
Add 2 text boxes on your form for beginning date and ending date. Then in your code, add coding something like "ReferralDa te BETWEEN #" & Forms!frmReport Selector!txtBeg inningDate & "# AND #" & Forms!frmReport Selector!txtEnd ingDate & "#".

Did that help???
Oct 13 '08 #2
falroc
4 New Member
Add 2 text boxes on your form for beginning date and ending date. Then in your code, add coding something like "ReferralDa te BETWEEN #" & Forms!frmReport Selector!txtBeg inningDate & "# AND #" & Forms!frmReport Selector!txtEnd ingDate & "#".

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
3037
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). I have a dataset as follows (1 week to keep it short): Employee 1 - Date 1 Employee 1 - Date 2
0
2075
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 from database to a VB.net app, they retrieve the database fields as a record set eg. "select name, suburb from myTable"
2
1495
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 that the OleDbCommand does not seem to recognise the Date parameter in the command string. Code follows:
1
9452
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 I try to create my SQL connection in the code-behind, I get the following error. I tried to register the DLL using regsvr32 but that errored out saying, "dllregisterserver entry point was not found". Any ideas? Retrieving the COM class factory...
15
1660
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 Public StrSql As String Set AdVehDecp = New ADODB.Connection Set RsQry = New ADODB.Recordset AdVehDecp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\VEHICLE_TRACKER.mdb;" AdVehDecp.Open
5
1983
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 data adaptor.fill or datareader to retrieve the data it takes over 24 seconds. public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime DateEnd, int status,...
2
1670
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 1:48:06 PM |
2
1733
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 DataSets, TableAdapters, DataViews, etc. 1. I have an Access database. One of the fields ("StartDate") is defined as a Date.
0
1501
by: chanlichin | last post by:
Select Case (cbMonth.Text) Case "January" Dates = "1" Case "February" Dates = "2" Case "March"
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.