Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    You read that before I edited post. Review again.

    Use the button, change the code.
    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.

  2. #17
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    Quote Originally Posted by June7 View Post
    You read that before I edited post. Review again.

    Use the button, change the code.
    LOL okay I will add back the Ok and Cancel buttons. I am a little confused now on code placement. What code is supposed to be on the Case Statement under the Form_frmDateCal/ReportType AfterUpdate Event? and what Code is supposed to be on the Okay button under the Form_frmDatePicker?

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Post 14 goes in frmDatePicker. That means the other code goes behind first form.

    An alternative to a form is looping code using InputBox.

    Code:
    Dim dteStart As Date, dteEnd As Date, strInput As String
    While Not IsDate(strInput) strInput = InputBox("Enter start date.", "Start Date", Date()) Wend dteStart = strInput
    While Not IsDate(strInput) strInput = InputBox("Enter end date.", "End Date", Date()) Wend dteEnd = strInput

    There is no escape for users (although it could be accommodated), they must enter valid values or accept the given defaults. And there is also no date picker calendar.



    Last edited by June7; 01-04-2020 at 02:01 PM.
    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.

  4. #19
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    I got this compile error when I select the Form two under the "FormType" Dropdown

    Click image for larger version. 

Name:	Capture.GIF 
Views:	11 
Size:	154.6 KB 
ID:	40595

  5. #20
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    I found the error. I fixed it. I had the code wrong on that highlighted part. i fixed it and now i have a new error on the Okay button on the Form_frmDatePicker

  6. #21
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    The new error is the same as in the picture but on the Form_frmDatePicker btnOkay_Click. the error is caused by the Me.tbxDataDialog

  7. #22
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    Here is a new copy of the database for your review. Can you please see what I did wrong? Thank you

    DatePicker2.zip

  8. #23
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    I GOT IT!!!! It is working... Thank you so much. I had to look a the code one more time in the Okay button and fixed it. I forgot to change to code you provided to me to the correct date text box name

  9. #24
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    Never Mind. So did some more testing. On the Form_frmDatePicker, if I leave one date blank and select Ok the ifNull statment runs correctly on that form but throws an error on the main form Form_frmDateCal. The error is on the DValue date Diff line of code. Attached in yet another copy of the database for your testing.

    Thank you


    DatePicker3.zip

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    My example was concerned with only 1 date. Your requirement is for 2 dates before allowing user to leave form. Probably also want txtEDate to be later than txtSDate.
    Code:
    Private Sub btnOkay_Click()
    If IsNull(Me.txtSDate) Or IsNull(Me.txtEDate) Then
        MsgBox "Enter date."
        If IsNull(Me.txtSDate) Then Me.txtSDate.SetFocus Else Me.txtEDate.SetFocus
    ElseIf Me.txtEDate < Me.txtSDate Then
        MsgBox "End date must be later than start date."
        Me.txtEDate.SetFocus
    Else
        Me.Visible = False
    End If
    End Sub


    Could set textbox DefaultValue property with Date().
    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. #26
    JoeJr is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    62
    Quote Originally Posted by June7 View Post
    My example was concerned with only 1 date. Your requirement is for 2 dates before allowing user to leave form. Probably also want txtEDate to be later than txtSDate.
    Code:
    Private Sub btnOkay_Click()
    If IsNull(Me.txtSDate) Or IsNull(Me.txtEDate) Then
        MsgBox "Enter date."
        If IsNull(Me.txtSDate) Then Me.txtSDate.SetFocus Else Me.txtEDate.SetFocus
    ElseIf Me.txtEDate < Me.txtSDate Then
        MsgBox "End date must be later than start date."
        Me.txtEDate.SetFocus
    Else
        Me.Visible = False
    End If
    End Sub


    Could set textbox DefaultValue property with Date().
    Thanks! That worked. I will also set the textbox value as you stated. Thank you again for all your help.

  12. #27
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I suggested setting textbox DefaultValue, not Value.
    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.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-22-2018, 12:59 PM
  2. Replies: 3
    Last Post: 02-16-2016, 05:02 PM
  3. Replies: 1
    Last Post: 07-09-2014, 07:13 AM
  4. DateDiff to include start date
    By AussieGal in forum Access
    Replies: 1
    Last Post: 05-07-2013, 02:50 PM
  5. Convert date format yyyymmdd for datediff
    By TEN in forum Programming
    Replies: 1
    Last Post: 06-17-2009, 09:35 PM

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