Results 1 to 5 of 5
  1. #1
    Art Wrok is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    3

    Build and pass a date


    I need a simple vba procedure to capture a year and a month from lists on a form and use them to return two dates, one for the first day of the month and one for the last day of the month, to text boxes on the form.
    The controls are named: lstYears, lstMonths, txtStrtDt, txtEndDt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Expressions in textboxes:

    =DateSerial([lstYears], [lstMonths], 1)

    =DateAdd("m",1,DateSerial([lstYears], [lstMonths], 1))-1
    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
    Art Wrok is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    3
    Thank you June7. That works! Now, as you might imagine, that is not the end. The reason for getting the dates is to pass them to a Report which I am able to do. But I found out something about reports. When I first created the report its data source was a table and opening the report showed all records in the table. Next I wrote a query that said "SELECT * FROM TABLE" which also shows all records. Then I added a WHERE Clause that said WHERE StartDate = Forms!MyForm!txtStrtDt AND EndDate = Forms!MyForm!txtEndDt. This allows me to show only selected records in the report. The problem is that when the date text boxes on the form are not populated the report shows No records instead of all. There are actually other controls on the form to select criteria and other parts of the WHERE Clause and unless all controls have a value the report shows nothing. I would like to put some kind of conditional logic in it that says if no criteria selected then show all records or else if one or more control has criteria then filter the report accordingly. Is this possible?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    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
    Art Wrok is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    3
    Thanks again. This looks like the solution.

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

Similar Threads

  1. Replies: 3
    Last Post: 11-26-2014, 01:01 PM
  2. Date pass parameter incorrect
    By WickidWe in forum Forms
    Replies: 2
    Last Post: 01-09-2014, 09:14 PM
  3. Pass date and open outlook
    By jaykappy in forum Programming
    Replies: 3
    Last Post: 10-04-2012, 07:06 AM
  4. filter date from Query pass down to report
    By geraldk in forum Reports
    Replies: 1
    Last Post: 08-17-2012, 10:14 AM
  5. 90 days in the pass - Date help wanted
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 01-26-2009, 07:13 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