Choosing a salutation based on time()

D

Douglas J. Steele

You could create a function along the lines of:

Function SelectGreeting() As String

If Time() >= #7:00:00# And Time() <= #12:00:00# Then
SelectGreeting = "Good Morning"
ElseIf Time() > #12:00:00# And Time() <= #18:00:00# Then
SelectGreeting = "Good Afternoon"
ElseIf Time() > #18:00:00# And Time() <= #23:59:59# Then
SelectGreeting = "Good Evening"
Else
SelectGreeting = "Go to bed!"
End If

End Function

and then simply call that function.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Derek Wittman said:
Good afternoon,
I would like to customize my macro-sent emails a bit. Instead of the
generic "Hello" greeting, I'd like to have:
Good morning,
Good afternoon,
and even Good evening,

based on the time of day that I execute the macro in question. I really
wouldn't care if I had to make 3 actions with conditions of Time() is
between 7:00 am and 12:00pm, etc. Is this really all I have to do? I know
that I can do Between dates in a query, but I'm just a bit unsure of putting
them as conditions in a macro. Should this be any different?
 
D

Douglas J. Steele

No, Time would probably be a better choice than Now, as you don't need the
date.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Derek Wittman said:
Should be Choosing a salutation based on Now()

Sorry,
Derek

----- Derek Wittman wrote: -----

Good afternoon,
I would like to customize my macro-sent emails a bit. Instead of the
generic "Hello" greeting, I'd like to have:
Good morning,
Good afternoon,
and even Good evening,

based on the time of day that I execute the macro in question. I
really wouldn't care if I had to make 3 actions with conditions of Time() is
between 7:00 am and 12:00pm, etc. Is this really all I have to do? I know
that I can do Between dates in a query, but I'm just a bit unsure of putting
them as conditions in a macro. Should this be any different?
 
G

Guest

Good afternoon,
I would like to customize my macro-sent emails a bit. Instead of the generic "Hello" greeting, I'd like to have:

Good morning,
Good afternoon,
and even Good evening,

based on the time of day that I execute the macro in question. I really wouldn't care if I had to make 3 actions with conditions of Time() is between 7:00 am and 12:00pm, etc. Is this really all I have to do? I know that I can do Between dates in a query, but I'm just a bit unsure of putting them as conditions in a macro. Should this be any different?

Thank you!
Derek
 
G

Guest

Should be Choosing a salutation based on Now(

Sorry
Dere

----- Derek Wittman wrote: ----

Good afternoon
I would like to customize my macro-sent emails a bit. Instead of the generic "Hello" greeting, I'd like to have

Good morning
Good afternoon
and even Good evening

based on the time of day that I execute the macro in question. I really wouldn't care if I had to make 3 actions with conditions of Time() is between 7:00 am and 12:00pm, etc. Is this really all I have to do? I know that I can do Between dates in a query, but I'm just a bit unsure of putting them as conditions in a macro. Should this be any different

Thank you
Derek
 
G

Guest

Thanks, Doug. Unfortunately, my experience with VBA is SPELLING it.

And if I can figure out how to make a function, how can I put the greeting in the email? (I guess I failed to explain, this was for a SendObject action in a macro

Dere

----- Douglas J. Steele wrote: ----

You could create a function along the lines of

Function SelectGreeting() As Strin

If Time() >= #7:00:00# And Time() <= #12:00:00# The
SelectGreeting = "Good Morning
ElseIf Time() > #12:00:00# And Time() <= #18:00:00# The
SelectGreeting = "Good Afternoon
ElseIf Time() > #18:00:00# And Time() <= #23:59:59# The
SelectGreeting = "Good Evening
Els
SelectGreeting = "Go to bed!
End I

End Functio

and then simply call that function

--
Doug Steele, Microsoft Access MV
http://I.Am/DougSteel
(No private e-mails, please



Derek Wittman said:
Good afternoon
I would like to customize my macro-sent emails a bit. Instead of th
generic "Hello" greeting, I'd like to have
Good afternoon
and even Good evening
wouldn't care if I had to make 3 actions with conditions of Time() i
between 7:00 am and 12:00pm, etc. Is this really all I have to do? I kno
that I can do Between dates in a query, but I'm just a bit unsure of puttin
them as conditions in a macro. Should this be any different
 
G

Guest

Dude! That is SO cool. I know it will work with a form, now. Time to check out the macro conditions!

Thanks!
Derek

----- Douglas J. Steele wrote: -----

No, Time would probably be a better choice than Now, as you don't need the
date.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Derek Wittman said:
Should be Choosing a salutation based on Now()
I would like to customize my macro-sent emails a bit. Instead of the
generic "Hello" greeting, I'd like to have:
Good afternoon,
and even Good evening,
really wouldn't care if I had to make 3 actions with conditions of Time() is
between 7:00 am and 12:00pm, etc. Is this really all I have to do? I know
that I can do Between dates in a query, but I'm just a bit unsure of putting
them as conditions in a macro. Should this be any different?
 
D

Douglas J. Steele

Does this mean you figured out how to create the function?

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Derek Wittman said:
Dude! That is SO cool. I know it will work with a form, now. Time to
check out the macro conditions!
 
G

Guest

Doug
Yes, it does. Thanks for your help! Now, I need to see if I can avoid calling it as a condition, and just put it in as the greeting somehow

Thanks
Dere

----- Douglas J. Steele wrote: ----

Does this mean you figured out how to create the function

--
Doug Steele, Microsoft Access MV
http://I.Am/DougSteel
(No private e-mails, please



Derek Wittman said:
Dude! That is SO cool. I know it will work with a form, now. Time t check out the macro conditions
Thanks Dere
----- Douglas J. Steele wrote: ----
No, Time would probably be a better choice than Now, as you don'
need th
date
Doug Steele, Microsoft Access MV
http://I.Am/DougSteel
(No private e-mails, please
 

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

Top