Timer Count Down

S

Stockwell43

Doug,

I have one last question:

Is there a way to disable the UserID field once time has expired so no one
can sneak in anymore bids and enable it when a new time is added? I'm asking
because if I am not here in the morning when it expires to disable it
manually I would like for it to disable on it's own. Just a thought not a
biggie.

Thanks!!!
 
D

Douglas J. Steele

Since I don't know exactly how your form is set up, it's difficult to give a
definitive answer, but try:

Private Sub Form_Timer()
Dim varExpiryDtm As Variant

varExpiryDtm = DLookup("ExpiryDtm", "Countdown")
If IsNull(varExpiryDtm) Then
Me.txtTimeRemaining = "No event to countdown."
Me.TimerInterval = 0
Else
If Now() >= varExpiryDtm Then
Me.txtTimeRemaining = varExpiryDtm & " has passed."
Me.TimerInterval = 0
Me.UserID.Enabled = False
Else
Me.txtTimeRemaining = DateDiff("s", Now(), varExpiryDtm) & _
" seconds remaining."
End If
End If

Alternatively (or in addition), use

Me.AllowAdditions = False
Me.AllowEdits = False
 
S

S.Stoddart

Douglas J. Steele said:
Sorry, you're the victim of word-wrap in the response.

That msgbox line should be all one line.

This should be correct without word-wrap:

Private Sub Form_Timer()
Dim varExpiryDtm As Variant

varExpiryDtm = DLookup("ExpiryDtm", "Countdown")
If IsNull(varExpiryDtm) Then
Me.TimerInterval = 0
Else
Me.txtTimeRemaining = DateDiff("s", Now(), varExpiryDtm) & _
" seconds remaining."
End If

End Sub

(note that there must be a space in front of that underscore character.)
 
S

S.Stoddart

Can anyone help me with a similar problem, I need to close a form after a
specified period of time, this code works perfectly, but is there a way I
can use the on open function to store the current time + say 20 minutes into
the countdown table?
 
D

Douglas J. Steele

Private Sub Form_Open(Cancel As Integer)

Dim strSQL As String

If DCount("*", "Countdown") = 0 Then
strSQL = "INSERT INTO Countdown(ExpiryDtm) " & _
"VALUES(" & _
Format(DateAdd("n", 20, Now()), "\#yyyy\-mm\-dd hh\:nn\:ss\#) & ")"
Else
strSQL = "UPDATE Countdown " & _
"SET ExpiryDtm = " & _
Format(DateAdd("n", 20, Now()), "\#yyyy\-mm\-dd hh\:nn\:ss\#)
End If

CurrentDb.Execute strSQL, dbFailOnError

End Sub
 
S

Steve Kilcher

Hi, been reading her and seems like a good place to get answers. I need help coding a countdown from a date specified in a txtBox on a form, which is linked to a table. I am not a coder and I just found about Time Interval but have no idea how to use it. Can someone give me a hand?

Thanks,

Steve
 
S

Steve Sanford

Hi, been reading her and seems like a good place to get answers.

Yes, it is.... but the people that get the best answers, quickest, ask
specific questions and give detailed information about their forms, tables,
names, etc.

Doesn't "Reverse Countdown" = CountUP??? :D

Sooo, table name, form name, control name, field name??? Countdown in Years,
months, days, hours, minutes, seconds???

Are you counting how many days until Christmas? Until you retire?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Timer of Form 4
countdown timer 2
Understanding Timer Pause Code 6
countdown timer 5
count down timer in ppt 1
(OT) Ebay count down counter.... 1
Getting a caption without naming the control 1
timer 4

Top