INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Check if date is 1st of the month

Check if date is 1st of the month

(OP)
Hi All

I m hoping this is simple one.. I just want to check if the date entered is 1st of the month, if not display a msgbox for user to correct?

Appreciate your help

thank you

Ali

RE: Check if date is 1st of the month

HI,

Give the user a year and month to select.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Check if date is 1st of the month

Here is one way you can check it, and if the date is NOT 1st of the month, you can make it to be the 1st of the month:

CODE

Dim datDate As Date

datDate = Date

If Day(datDate) = 1 Then
    MsgBox "Bingo!"
Else
    MsgBox "It is NOT a 1st of the month"
    MsgBox "Date entered will be 1/" & Month(datDate) & "/" & Year(datDate)
End If 

But I would go with Skip's suggestion.

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Check if date is 1st of the month

(OP)
Thank you will give it a try

RE: Check if date is 1st of the month

(OP)
I ve tried the code, unfortunately it does nt work, even if I select 1st of month its still picks up the else function

Ali

RE: Check if date is 1st of the month

The problem is HERE

CODE

Dim datDate As Date

datDate = Date

If Day(datDate) = 1 Then
    MsgBox "Bingo!"
Else
    MsgBox "It is NOT a 1st of the month"
    MsgBox "Date entered will be 1/" & Month(datDate) & "/" & Year(datDate)
End If 

Date is today's date!

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Check if date is 1st of the month

Andrzejek's code is an example of detecting if a wrong date is entered, and illustrates how to build the correct date in the Else statement (effectively implementing Skip's solution). It is not, hoever, a code complete solution for your post. He's hoping that, having pointed you in the right direction, you might be able to take the remaining steps yourself.

RE: Check if date is 1st of the month

(OP)
OK thanks i understand

RE: Check if date is 1st of the month

Why give the user a chance to fail? Give the user the options that cannot fail.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Check if date is 1st of the month

Right on, strongm thumbsup2

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close