none
MsgBox over 30 days RRS feed

  • Question

  • I need a message box to pop up if today's date is 30 over a particular form's version date.

    How do I write something like:

    Private Sub Form_Load()

    If Me.TodaysDatetxt > Me.Version Date +30 Then

    Msgbox "This version is Out of Date."

    End If

    End sub


    Thank you in advance for any help you can give me.


    Gee

    Monday, July 27, 2015 6:59 PM

Answers

  • I solved the problem by using Expression builder to show the DateDiff in a textbox (DateDifftxt) between another TextBox (TodaysDatetxt) and the VerstionDate field.  

    So, the DateDifftxt is:

    =DateDiff("d",[VersionDate].[TodaysDatetxt])

    Then, wrote VB:

    Private Sub form_Load()

    If Me.DateDifftxt > 31

    Msg Box "You have a Version that is over 30 days old and is out of date.", vbExclamation, "Out of Date Data"

    End If 

    End Sub




    Gee


    • Marked as answer by GretaF Monday, July 27, 2015 8:02 PM
    • Edited by GretaF Monday, July 27, 2015 8:03 PM
    Monday, July 27, 2015 8:02 PM

All replies

  • Private Sub Form_Load()
    
        If (Date() > Me.[Version Date] + 30) then
            MsgBox "The version is out of date.", vbExclamation, "Version Out of Date"
        End If
    
    End Sub

    • Proposed as answer by André Santo Monday, July 27, 2015 7:25 PM
    Monday, July 27, 2015 7:19 PM
  • That did not work...it will not accept the () after the word Date.

    Any other ideas please?


    Gee

    Monday, July 27, 2015 7:30 PM
  • That did not work...it will not accept the () after the word Date.

    Any other ideas please?


    Gee


    It's a function without arguments.  Access just automatically removes the parentheses.  It's not a problem.
    Monday, July 27, 2015 7:55 PM
  • I solved the problem by using Expression builder to show the DateDiff in a textbox (DateDifftxt) between another TextBox (TodaysDatetxt) and the VerstionDate field.  

    So, the DateDifftxt is:

    =DateDiff("d",[VersionDate].[TodaysDatetxt])

    Then, wrote VB:

    Private Sub form_Load()

    If Me.DateDifftxt > 31

    Msg Box "You have a Version that is over 30 days old and is out of date.", vbExclamation, "Out of Date Data"

    End If 

    End Sub




    Gee


    • Marked as answer by GretaF Monday, July 27, 2015 8:02 PM
    • Edited by GretaF Monday, July 27, 2015 8:03 PM
    Monday, July 27, 2015 8:02 PM
  • I solved the problem by using Expression builder to show the DateDiff in a textbox (DateDifftxt) between another TextBox (NOWtxt) and the VerstionDate field.  

    So, the DateDifftxt is:

    =DateDiff("d",[VersionDate].[TodaysDatetxt])

    Then, wrote VB:

    Private Sub form_Load()

    If Me.DateDifftxt > 31

    Msg Box "You have a Version that is over 30 days old and is out of date.", vbExclamation, "Out of Date Data"

    End If 

    End Sub




    Gee


    And how is TodaysDateTxt getting populated?  As far as I can tell, you've just added two unnecessary extra controls to your form.  The procedure above works just fine and there is no need to worry that Access removed the parentheses from the Date() function as I explained shortly following your concern about it.
    Monday, July 27, 2015 8:12 PM