Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Location
    Crick, just outside Rugby
    Posts
    42

    Thumbs up Unanswered: Countdown to a date

    Hi,

    I'm making a wedding planning database where the startup screen will display the names of the couple and the date that they are getting married. I also wanted to add a countdown to the event so you can see how long until you get married.

    I've already got a table to store this information, but I just don't know how to do a countdown timer in days, hours & minutes etc.

    Can someone help please?

    Thanks

    Sherri

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Here's some code to get you started:

    Code:
    Function CountDown() as String
      Dim dtmWed As Date, lngMin As Long, strCntDwn As String
      dtmWed = #6/1/2005 12:00:00 PM#
      'find the difference between the dates in you smallest unit (minutes)
      lngMin = DateDiff("n", Now(), dtmWed)
      'there are 1440 minutes in a day
      strCntDwn = CStr(Int(lngMin / 1440)) & " Days "
      lngMin = lngMin - Int(lngMin / 1440) * 1440
      '60 minutes in an hour
      strCntDwn = strCntDwn & CStr(Int(lngMin / 60)) & " Hours "
      lngMin = lngMin - Int(lngMin / 60) * 60
      strCntDwn = strCntDwn & CStr(lngMin) & " Mins "
      CountDown = strCntDwn
    End Function
    I'd call this from the form's on current event. I'd also call it from the form's OnTimer event. You can set the value using:

    Me!txtDaysLeft = CountDown
    Inspiration Through Fermentation

  3. #3
    Join Date
    Nov 2004
    Location
    Crick, just outside Rugby
    Posts
    42
    Thanks!

    I'll give it a go.

    Sherri

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •