Results 1 to 4 of 4
  1. #1
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35

    Query re-run for Tomorrow/Yesterday

    Hi,

    I have a basic restaurant booking database in the making. The query linked to the continuous form shows all bookings for the date entered or if blank then todays date -

    IIf(IsNull([Forms]![BookingsDiarySearch].[DiaryDateEntry]),Date(),[Forms]![BookingsDiarySearch].[DiaryDateEntry])



    This all works fine but once this has been run I then want to be able to view tomorrows or yesterdays diary by simply clicking a command button. Not sure how to go about doing it? Any advice would be great.

    Cheers

    Luke

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Have buttons 'View Yesterday' and 'View Tomorrow' then the filter criteria would be the current date plus or minus one day. So the buttons would modify the date value in the textbox with: Me.DiaryDateEntry=Date()+1 (or Date()-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
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35
    Thanks, although I'm still struggling. At present the 'DiaryDateEntry' tbo is on a separate form.

    With the new 'View Yesterday' cmd button for example, am I getting it to close form and then openform with filtered criteria . . . Is that correct?

    I may just be putting the filter in the wrong place, I am putting it in a macro (I don't know how to write the same instructions in vba).

    How do I get it to ensure it applies the filters using the date that has already been selected and currently being viewed. Do I need to be using a TempVar?

    Probably just confusing the matter!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Oh, sorry then replace the Me with [Forms]![BookingsDiarySearch]

    Because you are referencing the date as a parameter in the query the form is based on, this filters the form to a limited recordset. Changing the criteria requires requerying the RecordSource. It is not necessary to close then reopen the form to accomplish but that does work.

    I don't use macros, just VBA. Easier to debug and more versatile. But suppose in macro could use the form Requery method. It would be like [Forms]![BookingsDiarySearch].Requery
    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.

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