• Display Digital Clock in a form (97 SR1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Display Digital Clock in a form (97 SR1)

    Author
    Topic
    #366151

    Is it possible to have a digital clock in a form (showing hour, minutes, seconds) of the current time? Similar to the type that is on the bottom of the Windows screen. If so, how do I create one?

    Viewing 1 reply thread
    Author
    Replies
    • #566958

      * Open your form in Design view.
      * Open the Toolbox (select View, Toolbox from the main Access menu bar).
      * Click the Label button then click on the form to place the Label.
      * Right click on the Label and select Properties.
      * Under the Other tab of the Properties box, type Clock in the Name box. Close the Properties box.
      * On the main Access menu bar, select View, Properties.
      * Under the Event tab of the Properties box, click on the On Timer box, select Event Procedure, then press the small button with “…” on it.
      * Paste/type the following code into the Visual Basic window. Don’t repeat the Private Sub and End Sub declarations if they’re already shown:

      Private Sub Form_Timer()
      Clock.Caption = Format(Now(), “h:mm:ss AM/PM”)
      End Sub

      * Exit Visual Basic.
      * Under the Event tab of the Properties box, type 400 in the Timer Interval box.
      * Close the Properties box.
      * Exit and, if prompted, save your form.
      * Re-start your form…the Label should be presented as a digital clock.

      Good luck!

    • #566960

      A combination of a textbox and a timer event for the form will do it.
      Define a textbox to hold the time.
      Use a timer event to update the time in the textbox repeatedly using your preferred timer interval.
      You will find help about timer events in Access help.

      • #566967

        Well, we made our replies concurrently.

        To make the proposed code sequence work as I imagine you would like it to, reset the timer interval in the timer event, e.g.:
        Me.TimerInterval = 400 ‘ (or whatever timerinterval you need)

    Viewing 1 reply thread
    Reply To: Display Digital Clock in a form (97 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: