G
Guest
Objects are “Userformâ€, Textbox for Date(TxtDate), Textbox for
TrackNo(TxtTrackNo), Record Source(MyData) with TrackNo and Date as fields.
When user enters the Date on userform I need VBA procedure to count or sum
from the record source where the dates in table equal the year and month of
the date entered by user. This currently returns a number based on the entire
date and not the year/month part of the date.
IndexNo = DCount([Date], "MyData", [Date] = TxtDate.Value) + 1
Dates entered in record table field named Date
6/1/2005, 6/8/2005, 6/12/2005, 6/15/2006, 6/9/2006, 6/18/2006, 6/23/2006
User enters 6/25/2005 and I want the program to return 4 because there are 3
dates that equal the year 2005 and month 6 then adds 1 to the count/sum. My
goal is to use this to make tracking number for example: T0606-004 =
“Tâ€&Format(TxtDate.Value,â€yymmâ€)&â€-“& Format(IndexNo,â€000â€). If the user
entered 6/2/2007 then the IndexNo will equal 1 because there are no 2007 and
6 dates in the record table, it resets the TrackNo. I have been able do this
by year but cannot seem to figure how to do this by year and month.
I am highly grateful for any help you can offer. I am using Access 2003.
Thanks
TrackNo(TxtTrackNo), Record Source(MyData) with TrackNo and Date as fields.
When user enters the Date on userform I need VBA procedure to count or sum
from the record source where the dates in table equal the year and month of
the date entered by user. This currently returns a number based on the entire
date and not the year/month part of the date.
IndexNo = DCount([Date], "MyData", [Date] = TxtDate.Value) + 1
Dates entered in record table field named Date
6/1/2005, 6/8/2005, 6/12/2005, 6/15/2006, 6/9/2006, 6/18/2006, 6/23/2006
User enters 6/25/2005 and I want the program to return 4 because there are 3
dates that equal the year 2005 and month 6 then adds 1 to the count/sum. My
goal is to use this to make tracking number for example: T0606-004 =
“Tâ€&Format(TxtDate.Value,â€yymmâ€)&â€-“& Format(IndexNo,â€000â€). If the user
entered 6/2/2007 then the IndexNo will equal 1 because there are no 2007 and
6 dates in the record table, it resets the TrackNo. I have been able do this
by year but cannot seem to figure how to do this by year and month.
I am highly grateful for any help you can offer. I am using Access 2003.
Thanks