Kaup, Chester
Chester_Kaup at kindermorgan.com
Tue Sep 25 08:52:38 CDT 2007
Thanks everyone for your coding ideas. It almost works. The problem is
this. If the user does not enter a date it loops through the null error
check just fine. However when the user enters a valid date it displays
the message that the start date is after the end date when it is not. A
check of the code reveals that after a null check the next time a date
is entered the code thinks the date is text (puts quotes around it). I
tried a cdate on the start date but of course that doesn't work if it is
null. Ideas?
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gmail
Sent: Friday, September 21, 2007 2:20 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Resume command problem
I would change your code to:
Private Sub StartDate_Exit(Cancel As Integer)
If Forms![frm Manifold Chart]!StartDate > Forms![frm Manifold
Chart]!EndDate Then
MsgBox "Invalid Date. Start date must be before end date"
cancel = true
End If
End Sub
Also if "frm Manifold Chart" is your current form where this code exists
(and I suspect it is) then change it to
Private Sub StartDate_Exit(Cancel As Integer)
If Me!StartDate > Me!EndDate Then
MsgBox "Invalid Date. Start date must be before end date"
cancel = true
End If
End Sub
But, presumably your user will enter the Startdate before the Enddate.
I
would put some code in the OnCurrent:
me!EndDate.enabled = not isnull(me!StartDate)
HERE IS AN EXAMPLE of the whole thing:
Option Compare Database
Option Explicit
Private Sub Form_Current()
Me!EndDate.Enabled = Not IsNull(Me!StartDate)
End Sub
Private Sub StartDate_Exit(Cancel As Integer)
If Me!StartDate > Me!EndDate Then
MsgBox "Invalid Date. Start date must be before end date"
Cancel = True
ElseIf IsNull(Me!StartDate) Then
MsgBox "You must enter a start date"
Cancel = True
Else
Me!EndDate.Enabled = True
Me!EndDate.SetFocus
End If
End Sub
Private Sub EndDate_Exit(Cancel As Integer)
If Me!EndDate < Me!StartDate Then
MsgBox "Your End Date cannot be before the Start Date"
Cancel = True
ElseIf IsNull(Me!EndDate) Then
MsgBox "You must enter an End Date"
Cancel = True
End If
End Sub
Max
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester
Sent: Thursday, September 20, 2007 9:40 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Resume command problem
I need some way to go back and check the value in the text box again to
see
if a valid value has been entered. I may be doing this all the wrong
way?
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Susan Harkins
Sent: Thursday, September 20, 2007 3:31 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Resume command problem
Resume works as part of an error-handling statement/routine. In the
example
below, you don't need it.
Susan H.
I am having trouble using the resume command. Just don't have a good
understanding. Here is the code I am using with it. Just generates an
error
message of "Resume without error" What does it need to look like.
Thanks.
Private Sub StartDate_Exit(Cancel As Integer)
If Forms![frm Manifold Chart]!StartDate > Forms![frm Manifold
Chart]!EndDate Then
MsgBox "Invalid Date. Start date must be before end date"
End If
Resume
End Sub
Chester Kaup
Engineering Technician
Kinder Morgan CO2 Company, LLP
Office (432) 688-3797
FAX (432) 688-3799
No trees were killed in the sending of this message. However a large
number
of electrons were terribly inconvenienced.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.485 / Virus Database: 269.13.19/1008 - Release Date:
9/14/2007
8:59 AM
--
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