Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify 'Monday' With Code?

Status
Not open for further replies.

jt463

IS-IT--Management
Nov 23, 2005
134
I have read the FAQ that provides code for calculating the number of business days between two dates. What I am trying to do is to force my users to be required to enter a start date that is a Monday.

I am planning on using a calendar control, but it would be nice if I could also put in functionality that either defaults to the closest Monday to today's date or that would validate that the date entered is a Monday.

Is this possible in VB?

Thanks for your time.
 
Hi... Here is a way to start as a test

Create a new form
Create a calendar control on to the form (ActiveXCtl0)
Create 2 Textboxes (Text1, Text3)

[Code for the form]

Private Sub Form_Load()
Me.ActiveXCtl0.Value = Date 'preset calendar date
End Sub

Private Sub ActiveXCtl0_Click()
Me.Text1 = Me.ActiveXCtl0.Value 'place calendar date in the textbox
Me.Text3 = Me.ActiveXCtl0.Value - Weekday (Me.ActiveXCtl0.Value) + 2 'calculate the Monday date and place in textbox
Me.Refresh
End Sub

The value in Text3 will be the Monday date for any day in a week you click on.

Hope this helps........

 



Hi, The previous Monday for any date...
Code:
dMonday = Int(([AnyDate]-2)/7)*7+2


Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
That is brilliant!

I will give that a try.

The more I learn about Access, the more I realize that I don't know. Thanks for your time!
 
What part of this would i need to change to find the last thursday? i have messed around with this, and tried using it by subtracting 4 from the result, but I need it to return the previous weeks thursday if the program is run on a thursday (which it normally is).... Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top