You read that before I edited post. Review again.
Use the button, change the code.
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.
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?
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 StringWhile Not IsDate(strInput) strInput = InputBox("Enter start date.", "Start Date", Date()) Wend dteStart = strInputWhile 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.
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
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
Here is a new copy of the database for your review. Can you please see what I did wrong? Thank you
DatePicker2.zip
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
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
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.
Thanks! That worked. I will also set the textbox value as you stated. Thank you again for all your help.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().
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.