[AccessD] Resume command problem

max.wanadoo at gmail.com max.wanadoo at gmail.com
Tue Sep 25 09:18:47 CDT 2007


The code assumed that your control was bound to a DATE Field, not a TEXT
Field.
REgards
Max
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, September 25, 2007 3:09 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Resume command problem

Hi Chester

You may try to replace CDate() with CVDate().

/gustav

>>> Chester_Kaup at kindermorgan.com 25-09-2007 15:52 >>>
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


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list