Guest_imported
New member
- Jan 1, 1970
- 0
I have an access database that keeps tracks of commissions paid to our salespeople at my compnay. When the database opens, a "Main Menu" form appears as do a series of 2 InputBoxes to limit the dates to return in reports and forms. The first InputBox asks for the beginning date wanted and the second asks for the ending date. This works fine, but I have an input mask of "mm/dd/yyyy" because that is how they appear in the queries and tables. If you violate the input mask a run-time error appears with the options of End, Debug, and Help. I don't want this to appear to the user. Rather, I want a message box or something to warn them of their violation and force them to correct it. I know that I can use the OnError Method, but don't know exactly where to put it or how it works. Any help would be appreciated. Here is my code:
Thanks
Code:
Private Sub Form_Open(Cancel As Integer)
Dim strDATEV As String, strDATEV2 As String
DoCmd.OpenForm "frmTEXT", acNormal, , , , acHidden
strDATEV = InputBox("WHAT IS THE BEGINNING DATE?", _
"PLEASE ENTER FIRST DATE", (Date - 7))
Forms![frmTEXT].txtDATEV.SetFocus
Forms![frmTEXT].txtDATEV.Text = strDATEV
strDATEV2 = InputBox("WHAT IS THE ENDING DATE?", "PLEASE ENTER SECOND DATE", _
Date)
Forms![frmTEXT].txtDATEV2.SetFocus
Forms![frmTEXT].txtDATEV2.Text = strDATEV2
End Sub
Thanks