Charlotte Foust
cfoust at infostatsystems.com
Wed Oct 3 10:20:01 CDT 2007
At least part of my confusion is in which control's events you're trying to use. If you want to keep the focus, use the beforeupdate event of each control to call a validation routine. Just remember that you have to handle the situation where the other date hasn't yet been entered. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Tuesday, October 02, 2007 1:48 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Strange Command Button Behavior I tried moving the error checking code from the OnExit event to the AfterUpdate event but after the error check occurs the focus moves to the next text box. With the OnExit event the focus goes back to the textbox that has the bad value. Here is the error checking code. If IsNull(Me!StartDate) Then MsgBox "You must enter a start date" Cancel = True ElseIf CVDate(Me!StartDate) > CVDate(EndDate) Then MsgBox "Invalid Date. Start date must be before end date" Cancel = True Else Me!EndDate.Enabled = True Me!EndDate.SetFocus DoCmd.OpenQuery "qry All Manifolds Production for a Time Interval" Forms![frm All Manifolds Chart 90 Days].chtAllManifolds1.Requery Me.Repaint End If -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Monday, October 01, 2007 1:46 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Strange Command Button Behavior Another way might be use the AfterUpdate events instead to call a test that looks at both controls. I'm assuming you're cross checking the dates to be sure start is before end, etc? Charlotte Foust -