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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"For each" with fields 1

Status
Not open for further replies.

CharlesFS

Technical User
Dec 14, 2008
39
BR
Guys, i have two text field in access form.[date1] and [date2].

In field [date1] i put the initial date value and [date2] i put the end date value. like: [01/10/2009] [03/10/2009] Obs:format date(dd/mm/yyyy)

I need a code to call one sub for each date between fields [date1] and [date2] values.

Thanks a lot!

 
Hi,

First, you must convert each string to a real date.
Code:
dim dFrom as date, dThru as date
dFrom = datevalue(me.[date1]) ' assuming that your string in is in your regional settings format.
Then loop, incrimenting the date by one until you reach the second date.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thankyou SkipVought, but have you a sample code about:
"Then loop, incrimenting the date by one until you reach the second date."

Thanks a lot SkipVought
 
Code:
dim dFrom as date, dThru as date, dte as date
dFrom = datevalue(me.[date1]) ' assuming that your string in is in your regional settings format.
dThru = datevalue(me.[date2])
dte = dfrom
do
  dte = dte + 1
'do something
loop until dte > dthru
or
Code:
for dte = dfrom to dthru
'do something
next


Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
WOooooooohoooooo !!!!

SkipVought Thank you!
SkipVought Thank youuu!
SkipVought Thank youuuuu!
SkipVought Thank youuuuuuuu!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top