Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25

    A date query

    Ok so I am making a database for a dental practice.



    What I want to find out, is what patients haven't been to the dentist for five months, so that I letter can be sent out to them, So I would just like to be able to run the query and shows me everyone you visited the practice 5 months ago.

    (I have a field which is called 'Last Visit Date' where coincidently is when the last visited)

    Thank You
    Andrias

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    SELECT * FROM tablename WHERE [Last Visit Date] < DateAdd("m", -5, Date())
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    Thank you, but unfortunately i'm getting the sub query syntax error in this expressin is incorrect ???

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    There is no subquery in my example. Show your exact SQL statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    SQL for what, if it is for that query I don'r have one yet

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Then what is generating error message if you have not built a query?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    when i have added the Patients Id and the last date seen, and then in the criteria put what you said it comes with that message i told you about

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Don't know how to help you. I tested that expression in criteria and it works.

    The error msg occurs when you type the expression or when you run the query? Can you switch to SQL view and see the statement?

    Show statement or provide more info. Give sample data. Provide the project for direct analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    Ok

    So my two main tables are:
    Tbl_Patients which in has (Patient ID,Salutation,Surname,Name,Contact Number,E-Mail,Scheme,Last Date Seen, Address 1.2.3.4)

    The next is my Tbl_Dentist which has mostly the same
    I have a few minor tables just so that my table is relational.(Tbl_Salutation,Scheme, Price listing)

    I have already made some very basic open queries and a couple of parameter queries.

    I havent added any dates into my database yet, thinking about it now do i need atleast a few or not.

    And i have 1 form opening tbl_Staff

    Thats all the Info i can give you as you can see still a very basic table

    Thank You
    Andrias

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    You have date field with no dates? Entering values probably won't resolve the error you get but always helpful to test with data.

    You will have to provide the project so can analyze. Make copy, remove confidential data, run Compact & Repair, zip if still large, attach to post.

    That date field should probably be in another table of Visits if you care about patient history.

    BTW, advise to avoid spaces, special characters, punctuation (underscore is exception) in names, also avoid reserved words as full name.

    Name would be better as FirstName, E-Mail as eMail, Patient ID as PatientID
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25

    The Database

    Hopefully I've attached its a rar file if thats ok, and i completely forgot to add a couple of dates

    Thank You
    Andrias

  12. #12
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    oh yh and dont worry all of the dentists are made up and i haven't got round to entering some fake patients sorry

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Here is query I tested and it works.

    SELECT Tbl_Patients.* FROM Tbl_Patients
    WHERE (((Tbl_Patients.[Last Date Seen])<DateAdd("m",-5,Date())));
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Andrias14 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    25
    Now im getting the same syntax error, and when i run the query without the patient i get a message saying undifiened function WHERE in expression, could you just possibly send the copy you have and i can just work of that ??

    Thank You
    Andrias

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Okay, I named the query Qry_FiveMonthNotice

    EDIT: Purpose Served, file removed.
    Last edited by June7; 11-23-2011 at 01:28 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. query to update a date based on another date
    By tkendell in forum Access
    Replies: 3
    Last Post: 06-29-2011, 09:32 PM
  2. Date Query
    By vimrcds in forum Queries
    Replies: 2
    Last Post: 01-29-2011, 04:28 PM
  3. Date query help!!!
    By dduvvuru in forum Queries
    Replies: 2
    Last Post: 08-27-2010, 12:59 PM
  4. Date Query
    By drako28 in forum Queries
    Replies: 2
    Last Post: 09-10-2009, 11:11 AM
  5. Replies: 2
    Last Post: 07-31-2009, 06:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums