Results 1 to 5 of 5
  1. #1
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318

    Date Range with Error Message Box

    I have a Pop Up Form to enter a date range. I want the date range to come up blank so I'm doing the following

    On load

    Me.StartDate = ""
    Me.EndDate = ""



    If they enter an end date that is before the start date I want an error msg box to come up. I have the expression but don't know how to write it in VBA

    =IIf([EndDate]<[StartDate],MsgBox("The Ending Date cannot be before the Begining Date",0,"ERROR"))

    I want it to clear the end date field after the error message is closed. Don't know how to do that.

    Then I will have a command button that will take them to the report.

    On Click will be Me.Visible = False

    The Report will close the pop up form.

    A little help would be appreciated.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I would probably put the date validation in the code behind the on click event of the button along with opening the report. The code would go something like this:

    Code:
    If Me.EndDate < Me.StartDate Then
      MsgBox "The Ending Date cannot be before the Beginning Date", 0, "Error"
      
      Me.EndDate = Null
      Me.EndDate.SetFocus
      Exit Sub
    End If
    DoCmd.OpenReport "reportname"
    DoCmd.Close acForm, "yourform"
    BTW, the Me.Visible = False only hides the form; it does not close the form.

  3. #3
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    I'll have to have the Me.Visible to run some calculations. I'll close the form when I close the report. I'll work on your code and let you know how it goes. Thanks so much.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome

  5. #5
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    That worked great. Thanks!

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

Similar Threads

  1. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  2. Date range Q
    By markjet in forum Queries
    Replies: 13
    Last Post: 07-18-2011, 01:00 PM
  3. Date range
    By eacollie in forum Queries
    Replies: 7
    Last Post: 06-05-2011, 03:38 PM
  4. Error Message re: data entry of date
    By Pro-not in forum Access
    Replies: 9
    Last Post: 10-22-2010, 10:14 AM
  5. Date range help!!
    By bananatodd in forum Access
    Replies: 26
    Last Post: 10-18-2010, 01:57 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