|
-
July 2nd, 2001, 11:59 AM
#1
Can`t get DateDiff to work...
Hi,
I have a button on my form.
When I press the button, I want a timer/clock to start.
When I press the button again, I want the timer/clock to stop and I wan`t the time that has elapsed to appear on the screen.
Iam finding difficulties at the moment with DateDiff.
Can anyone give me any info on how i can do this?
Thanks
Mark
-
July 2nd, 2001, 12:41 PM
#2
Re: Can`t get DateDiff to work...
One command button and one text box
Option Explicit
Dim starttime As Date
Dim endtime As Date
Private Sub Command1_Click()
If Command1.Caption = "Stop" Then
endtime = Now
Text1 = DateDiff("s", starttime, endtime)
Exit Sub
End If
starttime = Now
Command1.Caption = "Stop"
End Sub
David Paulson
-
July 13th, 2004, 01:04 AM
#3
In my report request forms I provide data range filters.
Date From
Date To
I have the dataformat property set as Date ( format 13/07/2004 ).
Part of my processing involves validation to ensure the Date To is greater than the Date From.
This validation fails when the "Date From" is 30/04/2004 and "Date To" is 01/07/2004
I don't understand this, most program languages I have worked with are smart enough to know they are working with a date format? and successfully compare the above dates to know that 01/07/2004 is a later date?
How should I be setting up date fields on my forms and how should I be comparing the values to ensure the user has entered valid filter information.
In my code I use a format reassignment to include zeros where the user has entered single digits for dd and mm.
My current code is
If IsDate(txtDateFrom) Then
If IsDate(txtDateTo) Then
txtDateFrom = Format(txtDateFrom, "dd/mm/yyyy")
txtDateTo = Format(txtDateTo, "dd/mm/yyyy")
If txtDateFrom > txtDateTo Then
MsgBox "To date must be greater than From Date!"
txtDateFrom.SetFocus
AddFlag = "No"
End If
Else
MsgBox "To Date must have dd/mm/yyyy format! "
txtDateTo.SetFocus
AddFlag = "No"
End If
Else
MsgBox "From Date must have dd/mm/yyyy format! "
txtDateFrom.SetFocus
AddFlag = "No"
End If
Last edited by T2T2; July 13th, 2004 at 01:18 AM.
TT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|