datediff question

W

WP

Hi all
I have created a word .dot that uses a form for input and the submissions
from the form are added to the document in the correct bookmarks. On the form
I have 2 calanders(due date and event date). I need to have the form have a
message box popup and the doc become read only if the date that is clicked on
the due date calander is 5 days or less from the current date.
ie: the user selects July 21 on the calander and todays date is July 19
I am fairly new to all this. I have seen lots of different code to do this
but I dont know how to apply it to the on click event of the calander
TIA
Wayne
 
O

old man

Hi,

What calendar control are you using to get the date? Are you using a textbox?

old man
 
O

old man

Hi,

Here is code you can start with. I don't know if you want to allow the fifth
day as valid.

Private Sub Calendar1_Click()
Dim curdate As Date
Dim chkdate As Date
Dim numdays As Integer

curdate = Now
chkdate = DateSerial(Calendar1.Year, Calendar1.Month, Calendar1.Day)
numdays = DateDiff("d", curdate, chkdate) - 1
If numdays < 0 Or numdays > 4 Then
MsgBox "Not in Range"
End If


End Sub

Old Man
 

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

Similar Threads


Top