Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redundant Error Handling 1

Status
Not open for further replies.

VBADb

Programmer
Joined
Jul 30, 2004
Messages
11
Location
US

I'm trying to enter a date thru an input box with error checking. The code is included at the end. If the date is wrong I want to re-display the input box. My problem is that the input box is re-displayed on the first error but if I re-enter a bad value again (ex. 13/41/04) I get the ugly Access "Type Mis-match Error" box which asks me to end or debug. How do you get the input box to re-appear till they get it right?

The code...

Sub ReportDate()

On Error GoTo ErrorTrap

ReportDate = Nz(InputBox("Enter a Date: mm/dd/yy"), Date)
reportYear = Year(ReportDate)
reportMonth = MonthName(Month(ReportDate), True)
Exit Sub

ErrorTrap:
Resume

End Sub

Thanks for any help, George
 
start:
reportdate=InputBox("Enter a date", "Title", Format(Date, "mm/dd/yyyy"))
If Not IsDate(reportdate) Then GoTo start


reportYear = Year(ReportDate)
reportMonth = MonthName(Month(ReportDate), True)
Exit Sub

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Do
ReportDate = InputBox("Enter a Date: mm/dd/yy", , Date)
Loop Until IsDate(ReportDate)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top