Time problems

  • Thread starter Thread starter DJN
  • Start date Start date
D

DJN

Guest
I have the following procedure that reads DisplayTime
and CompactTime from a dbtable. If now() is between DisplayTime and
CompactTime it should change the caption of the open forms to read the time
but it never gets to display the caption as the formula never works out.

What have I done wrong ??

Private Sub Form_Timer()
Dim i As Integer
If Format(Now(), "hh:mm:ss") > DisplayTime And Format(Now(), "hh:mm:ss")< CompactTime Then

For i = 0 To Forms.Count - 1
Forms(i).Caption = "Current time = " & Format(Now, "hh:mm:ss") & " Database close time = " & CloseTime

Next i
End If
End Sub

The problem seems to be associated with the if Format line. The two statements on their own seem to work but when the AND is added it fails.
Any help would be appreciated.
 
Hi,

i just tried your formula and it worked fine - how are you setting compact and display?

Drew
 
Thanks for replying Drew,

Strange, I have just run it again and nothing. The caption has not changed. I have set both Display and Compact as variant Display is set to 1:00:00 and Compact 4:00:00 so I should have the message in the caption.
 
ie just tried with variants and strings in case that was knocking it off as i'd used dates originaly but it still works fine with either, all i can think is that you could try
Forms(i).Repaint to make sure it is redrawing each form. I that doesn't help i'm stumped, sorry

Drew
 

Users who are viewing this thread

Back
Top Bottom