Results 1 to 12 of 12
  1. #1
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83

    PopUps

    Hi Guys

    Please can you help with adding a popup In my DB

    GOAL
    I need a simple popup that appears when I open the DB to remind the user to process / capture the salaries on the last day of every month.

    I have a PopUpDateTbl table with fields PopUpID_Fk and Date

    I have a PopUpTaskTbl table with fields PopUpID_Pk and TaskDateOrigin and Task and DueDate

    I Have a PopUpTaskQry Query with Fields Task and Date with a report that matches

    DIFFICULTIES



    1. What code do I use to have the popup apper when the DB is opened on the last day of the month?
    2. Where do I put the code? Query/report/form/switchboard

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    on the switchboard,in the form LOAD event, check the popup table:

    you could open a form (pop up modal mode) to show the items in the table that meet the date.


    for last day of month:


    LastDayOMonth: dateadd("d",-1,dateadd("m",1,month(date()) & "/1/" & year(date())))


    if Date()=dateadd("d",-1,dateadd("m",1,Date())) then msgBox "Run Salaries"

  3. #3
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Thanks ranman256

    Do I open the switchboard in design view then create an event in the event tab under "on load"?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    yes, then write in the end-o-month code.

    If your queries can determine date they too can open as a 'datasheet' to show whats needed.
    if Dcount("*","qsDatesDue")>0 then docmd.openquery "qsDatesDue"

    or like that.

  5. #5
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Ok I used the code if Date()=dateadd("d",-1,dateadd("m",1,Date())) then msgBox "Run Salaries"
    as you suggested in the On Load event of the switchboard. I did not get any errors but it does not seem to do anything. What am I missing and doing wrong?

    Click image for larger version. 

Name:	Switchboard.jpg 
Views:	10 
Size:	30.6 KB 
ID:	31377

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I tested the expression: DateAdd("d",-1,DateAdd("m",1,Date()))

    Today's date is 11/21/2017, the calc returns 12/20/2017.

    Simpler expression to return last day of month: DateSerial(Year(Date), Month(Date) + 1, 0)
    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.

  7. #7
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Hi June7

    I don't understand

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Edited my previous post, possibly after you read it.

    Ranman is suggesting code that will popup a message box on the last day of the month.
    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.

  9. #9
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Like this?

    Click image for larger version. 

Name:	Switchboard.jpg 
Views:	10 
Size:	10.3 KB 
ID:	31378

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Yes, so nothing will 'happen' until the last day of the month when user should get the MsgBox popup. The code runs every time the form opens, just no message unless it is the last day of the month.
    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.

  11. #11
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    thank you very much. I don't want to be annoying but is there a way for me to test it now?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Test what? Whether the procedure runs? Or if the DateSerial correctly calculates? Or if Date = the calc.

    Set a breakpoint on the If line in the procedure and execution will stop there and you can step through to see how it progresses.

    Use VBA Intermediate Window to test code. Type in the window and press Enter after each line:

    x = #11/30/2017#
    If x = DateSerial(Year(Date()), Month(Date()) + 1, 0) Then MsgBox "Run Salaries"
    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