Timed Messages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Patrick

    Timed Messages

    Hi All

    Got a great code that displays Good Morning / Good Afternoon / Good Evening
    depending on the system time from:



    Looks great and the idea is brill - however it keeps displaying "Good
    Evening" = regardless of the time.

    The code is:

    If Time() < 0.5 Then
    [lblMorning].Visible = True
    [lblAfternoon].Visible = False
    [lblEvening].Visible = False

    ElseIf Time() > 0.5 And Time() < 0.75 Then
    [lblMorning].Visible = False
    [lblAfternoon].Visible = True
    [lblEvening].Visible = False

    ElseIf Time() > 0.75 Then
    [lblMorning].Visible = False
    [lblAfternoon].Visible = False
    [lblEvening].Visible = True
    End If
    End Sub

    Anyone help??

    Thanks

    Steve


  • Keith Wilby

    #2
    Re: Timed Messages

    "Steve Patrick" <sp014a7590@blu eyonder.co.uk> wrote:
    [color=blue]
    > Got a great code that displays Good Morning / Good Afternoon / Good
    > Evening depending on the system time from:
    >
    > http://www.microsoft-accesssolutions...me_message.htm
    >
    > Looks great and the idea is brill - however it keeps displaying "Good
    > Evening" = regardless of the time.[/color]

    Hi Steve,

    I've seen some junk in my time but that takes the biscuit! You need only
    one label and set it's 'caption' property accordingly, summat like (not
    tested):

    Dim varTime As Variant, strLegend As String

    varTime = Time()
    If varTime > "00:00:01" And varTime < "12:00" Then strLegend = "Good
    Morning"
    If varTime >= "12:00" And varTime < "18:00" Then strLegend = "Good
    Afternoon"
    If varTime >= "18:00" And varTime < "23:59" Then strLegend = "Good Evening"
    Me.lblGreeting. Caption = strLegend

    Regards,
    Keith.

    Comment

    • Pieter Linden

      #3
      Re: Timed Messages

      this works... ugly, but it works. (Kinda like me... ugly, but I have a pulse...)

      Private Sub Command6_Click( )
      Dim lngHours As Integer
      lngHours = DatePart("h", Me.txtTime)
      Select Case lngHours
      Case Is < 12
      Me.txtGreeting = "Morning"
      Case 12 To 17
      Me.txtGreeting = "Afternoon"
      Case Else
      Me.txtGreeting = "Evening"
      End Select

      End Sub

      Comment

      • Steve Patrick

        #4
        Re: Timed Messages

        Thanks Keith

        Somewhat of a newbie here - so I need some further help if poss.

        Do I still need to creat 3 lables (or Text boxes)?

        What goes into the caption line on properties of the lable lables?

        Where does the code go - is it in the properties of the lable / lables
        or of the form?

        Sorry to be a pain - I will get the hang of t all at some point.

        Steve




        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Keith Wilby

          #5
          Re: Timed Messages

          Steve Patrick <stevenpatrick@ blueyonder.co.u k> wrote:
          [color=blue]
          > Do I still need to creat 3 lables (or Text boxes)?[/color]

          No, just one label is required called (for example) "lblGreetin g".
          [color=blue]
          >
          > What goes into the caption line on properties of the lable lables?[/color]

          You can type whatever you want into the label's "Caption" property because
          the code will overwrite it.
          [color=blue]
          >
          > Where does the code go - is it in the properties of the lable / lables
          > or of the form?[/color]

          The code goes in the "On Load" event of the form. Select the form's
          properties and go to the Event tab. Click in the "On Load" property box
          and select "Event procedure" from the drop-down, then click the button to
          the right of the property box (it has 3 dots in it). Put the code between
          "Private Sub Form_Load()" and "End Sub" - note that these need to be on
          their own lines.

          I'm assuming Access 97 here - compile the code using the menu item
          Debug/Compile and save all ...[color=blue]
          >
          > Sorry to be a pain - I will get the hang of t all at some point.[/color]

          No problem :o)

          Comment

          Working...