Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9

    Queries based on a date field


    I hope someone can help.
    I have a database with a dashboard that i created. I have the dashboard working to enter information and search. I have two date fields in the table. I want to have a popup alert or message appear when i open the dashboard showing a message from these date fields. I would like the code to be within 30 days of the date in the two fields.

    How can i get the queries to work and also load on opening the dashboard.

    Thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    You want the dates to fill? What dates?
    The query would pull the dates from the form
    TxtStartDate on the form. (Unbound)
    txtEndDate source= DateAdd("d",30,txtStartDate)

    the query would use:
    select * from table where date between forms!myForm!txtStartDate and forms!myForm!txtEndDate

  3. #3
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    I would have a date in two different fields (i.e. 5/11/2017) and would want a popup thirty days before the actual due date. The when i open the dashboard i would see a message that there are upcing renewal and click to show all the records.

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The dashboard will have the table as its record source. When it opens (OnLoad event), write some code that says:
    If datefield is < Date()-29 then display MsgBox

  5. #5
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    It is the writting of the code is my issue, i an not fluent in getting all the code correct to make it work

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Code:
    If Me!yourdatefieldname < Date()-29 Then
        MsgBox "put your message here"
    End If

  7. #7
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    I entered the code and changed to my field name but get this error
    The expression On Load you entered as the event property setting produced the following error: Invalid outside procedure

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Post the code for this event.

  9. #9
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    If Me!rabiesduedate < Date - 30 Then
    MsgBox "Vaccinations are due"
    End If

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Post the entire subroutine (double-click inside of it and it will select all the code). Change the message to Me!rabiesduedate & "..msg.." which will display your date and you can see if the date is valid.

  11. #11
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    There should be more code that is needed, but just not sure


    If Me!rabiesduedate < Date - 30 Then
    MsgBox "Vaccinations are due"
    End If




    Private Sub Form_Load()


    End Sub

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Code:
    Private Sub Form_Load()
    
    If Me!rabiesduedate < Date - 30 Then
        MsgBox "Vaccinations are due"
    End If
    
    End Sub
    Not sure this will really accomplish what you want. If Dashboard is bound to dataset (is it displaying records in Continuous view?). The code will read rabiesduedate from the first record only.

    In post 3 what is 'upcing'?

    If you want to provide db for analysis, follow instructions at bottom of my post. If zip still too large, can upload to fileshare site such as Box.com and post link to file.
    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.

  13. #13
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The code must be inside the subroutine:
    Private sub
    ..code...
    End Sub

  14. #14
    mstrbfg is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    9
    i pasted the code, now i get a runtime error 2465. Microsoft access cannot fird rabiesduedate referenced to the expression. My table has the field

  15. #15
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    But is the table the record source for the form, and is the field on the form bound to the table?

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

Similar Threads

  1. Replies: 4
    Last Post: 04-25-2015, 04:17 PM
  2. Replies: 2
    Last Post: 05-22-2014, 06:11 PM
  3. Replies: 6
    Last Post: 11-13-2013, 04:17 PM
  4. Replies: 1
    Last Post: 01-29-2012, 01:06 PM
  5. 2 Queries on one Date Field
    By LaPixie in forum Queries
    Replies: 1
    Last Post: 08-22-2011, 02:22 PM

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