Results 1 to 4 of 4
  1. #1
    dgtampa is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    28

    DatePicker and Parameter Query

    Hello,



    I have been working on this for a few hours and have found much information on various forums, but I am having trouble incorporating what I have learned into the DB that I have.

    I have a query which members of this forum have (very graciously) helped me develop (please see this thread for details on my DB and on the parameter query in question).

    I would like to add one thing to the "design" of the query; I would like to have a DatePicker pop up to enter the parameter instead of the default parameter-entry dialogue box. Everything I have read on the web says I cannot do this directly through the query. Instead, it seems I must first create an unbound form (frmStart_Schedule) using a TextBox (cboDatePick) with format set for Date/Time to provide the parameter for the query.


    Click image for larger version. 

Name:	frmStart_Schedule.jpg 
Views:	13 
Size:	69.0 KB 
ID:	7749

    What I am having trouble with is having the SQL code "point" toward the value entered in cboDatePick in order to run the query (which contains the user-defined function DoReview, which is in the other thread).

    Click image for larger version. 

Name:	qryLevel_Reviews.jpg 
Views:	12 
Size:	70.1 KB 
ID:	7750

    I don't know if I am making myself clear or not; I appreciate any help and please let me know what additional information I need to provide in order to get that help!

    Thanks in advance!

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    this might help to get you started.

    http://www.datapigtechnologies.com/f...earchform.html

  3. #3
    dgtampa is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    28
    Quote Originally Posted by alansidman View Post
    this might help to get you started.

    http://www.datapigtechnologies.com/f...earchform.html
    Thank you Alan!

    I can see that at least I am already on the right track with the design of my small form. I have a text box in there; the format is set so that a DatePicker is triggered. I also have a query already created which I would like the form to run once the user chooses a date. I would like the date value entered through the DatePicker on the form to be used in the query.

    Here is my problem: the query uses a user-defined VBA function called "DoReview" (which I didn't create) and the query itself doesn't make sense to me in the context of instructional videos and/or web-pages like the one you referred me to. Whenever I try to insert the full name of the text box from the form (Forms![frmStart_Schedule]![cboDatePick]) into the query as an argument in SQL view, or as a criteria in the query design view, I either get an error, or I continue to get the regular "Enter Parameter" dialogue box, even with frmStart_Schedule open in another tab.

    Here is the VBA function code:

    Code:
    Function DoReview(ThursDate As Date, Admit_Date As Date) As Boolean
    Dim SunBef As Date, SatAf As Date
    Dim AdmitDay As Integer, Sun_Day As Integer, Sat_Day As Integer
    SunBef = DateSerial(Year(ThursDate), Month(ThursDate), Day(ThursDate) - 4)  'Date of the preceding Sunday
    SatAf = DateSerial(Year(ThursDate), Month(ThursDate), Day(ThursDate) + 2)   'Date of the subsequent Saturday
    Sun_Day = Day(SunBef)   'Day of the month
    Sat_Day = Day(SatAf)
    AdmitDay = Day(Admit_Date)
    DoReview = False
    If Sun_Day < Sat_Day Then   'week contained in a single month
        If AdmitDay >= Sun_Day And AdmitDay <= Sat_Day Then
            DoReview = True
        End If
      Else                      'week ending on next month
        If AdmitDay >= Sun_Day Or AdmitDay <= Sat_Day Then
            DoReview = True
        End If
    End If
    End Function
    And here is the Query:

    Code:
    PARAMETERS [Enter Review Date] DateTime;
    SELECT tblLevel_Review.Beneficiary_Name, tblLevel_Review.Current_Level, tblLevel_Review.Review_Date
    FROM tblLevel_Review
    WHERE (((DoReview([Enter review date],[Review_Date]))<>False))
    ORDER BY tblLevel_Review.Current_Level;
    I've attached a relationship report Attachment 7772

    Attachment 7772
    I'm new at SQL and VBA language rules, so my learning curve is slow right now. I might be going about it all wrong...
    Last edited by dgtampa; 05-23-2012 at 05:19 PM. Reason: clarification

  4. #4
    dgtampa is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    28
    I wound up solving it myself...I needed to add the identifier string for the control (Forms![frmStart_Schedule]![cboDatePick]) in the query in two places: in the PARAMETERS portion as well as in the argument portion in my WHERE clause after the user-defined function "DoReview".

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DatePicker
    By jle0003 in forum Access
    Replies: 2
    Last Post: 04-04-2012, 04:51 PM
  2. Replies: 13
    Last Post: 01-10-2012, 09:56 AM
  3. Datepicker set to short date: displays time?
    By sprovoyeur in forum Forms
    Replies: 3
    Last Post: 07-19-2011, 06:24 AM
  4. Replies: 1
    Last Post: 07-11-2011, 04:35 AM
  5. ActiveX Control calendar (datepicker)
    By aakann in forum Programming
    Replies: 16
    Last Post: 12-22-2010, 10:33 AM

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