Results 1 to 6 of 6
  1. #1
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272

    Greeting message in access database

    I have a form which i applied these codes to help display “Good morning”, “ Good Afternoon” & “Good Evening” at the appropriate times on a form.

    Below are the codes I used…

    “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”

    My issue is, when the form is already opened say in the morning, when the time is 12pm, it doesn’t change automatically to afternoon unless I close the database and open it again for it to display as afternoon. The same happens for the evening too.



    I have applied the codes to the onload event, also tried on the current event.

    But the problem persist. How do I fix this?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you must turn on the timer on the form.
    set an interval time to update the msg.

    your code above would be in : sub SetTimeMsg

    Run the code,SetTimeMsg, when the form opens, FORM_LOAD
    and in the sub TIMER_EVENT

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You only need one label which is always visible. Just change the label caption to Good morning/afternoon evening on the timer event code.
    Set the timer interval to 21,600,000 as that's the number of milliseconds in 6 hours =0.25 days.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I don't see the sense in doing any more than greeting on form open, and only if that form is a startup form. A greeting is a one time thing, no? If 2 people meet in the same locale they greet each other once "Good morning". After a few hours they go for lunch and meet up again at the same place after. Do they say "Good afternoon"? I think not likely. Besides, a timer with any span will always be late at some point. If I start the app at 10:00 AM, 6 hours later the greeting is 2 hours late, notwithstanding that it's only required once, so that form should not be a normally used form unless you set some sort of flag to prevent repetition.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by ranman256 View Post
    you must turn on the timer on the form.
    set an interval time to update the msg.

    your code above would be in : sub SetTimeMsg

    Run the code,SetTimeMsg, when the form opens, FORM_LOAD
    and in the sub TIMER_EVENT
    Can you give a practical example of your explanation?
    Am finding it difficult to understand what you mean

  6. #6
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Got it now
    Thanks to you all for your time

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-31-2020, 08:59 AM
  2. Replies: 12
    Last Post: 11-14-2016, 09:39 AM
  3. Replies: 6
    Last Post: 08-08-2016, 06:42 AM
  4. Replies: 6
    Last Post: 02-06-2015, 04:10 PM
  5. Replies: 4
    Last Post: 07-06-2012, 07:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums