SQL string problem - pleaze hellp!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The following actually creates a query but with nothing in it, even in cases
where I am sure there are patients with "DDate" in the moth specified by my
attempted restriction. That is strSQL ends up as:
SELECT * FROM tblPatients WHERE DDate >= 4/1/2005 AND DDate <= 4/30/2005;
It's Access97. Any help would be greatly appreciated!
-Paul H.


Select Case Me.cbxMonth.Value
Case 1, 3, 5, 7, 8, 10, 12
intLastDay = 31
Case 4, 6, 9, 11
intLastDay = 30
Case 2
If Me.txtYear.Value Mod 4 <> 0 Then
intLastDay = 28
ElseIf Me.txtYear.Value Mod 400 = 0 Then
intLastDay = 29
ElseIf Me.txtYear.Value Mod 100 = 0 Then
intLastDay = 28
End If
End Select

strSQL = "SELECT * FROM tblPatients WHERE DDate >= " & Me.cbxMonth.Value & "/1/"
& Me.txtYear.Value & _
" AND DDate <= " & Me.cbxMonth.Value & "/" & intLastDay & "/" & Me.txtYear.Value
& ";"

Set db = CurrentDb
With db
Set qdf = .CreateQueryDef("qryTest", strSQL)
End With


--
I keep hitting "Esc" -- but I'm still here!
.



Relevant Pages

  • how do i set up a query for mondays only
    ... i would like to be able to set up a query so that if a monday is seleced on ... patients. ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Re: Creating queries asking for counts
    ... That is the query and it should be entered into the SQL view not the query design view. ... COUNTAS [Number of Patients] ... GROUP BY "Type 1 diabetes" ... UNION ALL ...
    (microsoft.public.access.queries)
  • Re: complex filter and calculations in access
    ... First, you already said that you'd have a Table containing information on surgeons, so I set up an example containing two records. ... Since each one may be used more than once, it avoids duplicating information such as the surgeon's name that would otherwise take extra space in the [Patients] Table, and even worse, cause confusion in case the surgeon's name were misspelled in some records. ... Next, I count the number of post-op infections on record for patients linked to each surgeon, and I calculate relevant infection rates (based partly on the values returned by the Query). ...
    (microsoft.public.access.queries)
  • Re: Counting mulitple groups
    ... I don't understand what the query is attempting to accomplish and i, ... >> then the Devices that belong to each unit in that facility. ... >> used to test patients as well. ... >> count duplicates. ...
    (microsoft.public.access.queries)
  • RE: 1 form, 2 tables
    ... If there is a one to one relationship between patients and tests, ... The recordset can be a table or a query. ... include controls from in your same form. ... The two tables have a 1-to-1 relationship based on PtID. ...
    (microsoft.public.access.forms)