Results 1 to 4 of 4
  1. #1
    scruz is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2

    Heeelllpp!

    Hi. I'm new to Access so hopefully I can explain this clearly.
    I have a form connected to a report so the user can choose the report name (I plan on adding more than one in the future), then use a combo box to select an employee name, then enter a date range, 3/1/16 in the Date From box and 4/1/16 in the Date To box, for example, so the report will show records only between those dates.
    My form is based on a query which gets its info from a table with the employee's name, week ending date, check date and check amount.
    Sometimes our employees need a printout of their gross wages listed week by week.
    I just set up Access for our office around mid-February so I only have employee wages from the beginning of the year in my table.
    The form is set up so the report can be opened as Print Preview or Print. When I preview the report, it shows all their wages back to Jan 1st regardless of the dates I enter. I've been working on this for two weeks (obviously don't know what I'm doing!) and I'm stuck.
    This is my code (which I found online because clearly I don't know how to write this yet) for the dates but I'm missing something since it's not selecting the dates I enter. I would be grateful for any help to get over this hump.
    Thanks!

    Dim strFilt As String


    SetFilter = "[Date] BETWEEN #" & txtDateFrom & "# & #" & txtDateTo & "#"
    Me.Filter = strFilt
    Me.FilterOn = True

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Easier and better to create a query for the report rather than use vba, which is better left for a time when you have more experience - unless you're ok with copying and pasting stuff you don't understand. Also, if [Date] is the name of your field, that is bad (it's a reserved word). If it's not, then that's not how you use the Date function.

    In the criteria grid in design view for your report query, use this reference syntax to get the values from the controls on your form. When testing this query, the form has to be open in form view, not design view.
    Code:
    Forms!NameOfYourForm.NameOfYourControl
    e.g. in the FName field (translate to your own names)
    Forms!NameOfYourForm.txtFname
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    scruz is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2
    Thanks for the reply. For some reason this isn't working for me either. I just need to put this away and come back to another time.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Probably best that you continue on with this thread to prevent having two for the same issue, or mark this one solved at this point so people don't keep opening it for no reason.
    Good luck.

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

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