Kaup, Chester
Chester_Kaup at kindermorgan.com
Tue Oct 2 15:48:21 CDT 2007
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 -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Monday, October 01, 2007 11:20 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Strange Command Button Behavior I was using OnExit events on a start date and end date text boxes on the form to perform data validation. Maybe there is a better way to do this? -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Monday, October 01, 2007 11:12 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Strange Command Button Behavior First examine why you have OnExit events there. If this is in a header, you can't have all that many controls in it. Why not just use tab order and skip the OnExit. Setting a focus in OnExit can drive a user crazy. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Monday, October 01, 2007 9:08 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Strange Command Button Behavior Exactly. The OnExit event of the TextBox StartDate runs instead of the print command. How to detect the command button click and bypass the on OnExit Event??? -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Monday, October 01, 2007 10:53 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Strange Command Button Behavior Hi Chester and Charlotte - or an OnExit at StartDate ... /gustav >>> cfoust at infostatsystems.com 01-10-2007 17:46 >>> Chester, It isn't the button click code that's the problem. Have you put in break points to be sure the click event is actually occurring the first time you click it? It sounds like you might have an OnEnter event firing first. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester Sent: Monday, October 01, 2007 7:28 AM To: Access Developers discussion and problem solving Subject: [AccessD] Strange Command Button Behavior I have a command button in the header of form to print a report. When I click on the button the focus moves from a text box on the form named StartDate to a text box on the form named EndDate. The report does not print. The second time I click the command button the form prints. Code for the command button is below. I tried compacting and repairing the database and moving everything to a new form but to no avail. Private Sub Command1_Click() On Error GoTo Err_Command1_Click Dim stDocName As String stDocName = "rpt All Manifolds Oil Gas Water 90 Days" DoCmd.OpenReport stDocName, acNormal Exit_Command1_Click: Exit Sub Err_Command1_Click: MsgBox Err.Description Resume Exit_Command1_Click End Sub Chester Kaup Engineering Technician Kinder Morgan CO2 Company, LLP Office (432) 688-3797 FAX (432) 688-3799 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com