I have an application that uses a date range to pull in a file for import. The filenames are by daterange (i.e., Filename0531.tx t, Filename0601.tx t, etc). I have the app set to automatically open the form and enter the startdate and enddate based upon today's date. (I.e., today is 06/02, the startdate of the form would be 05/31/2008 and the enddate would be 06/02/2008). The code loops through using a counter but I'm having problems. It worked up until today (I assume since the end of the month fell on a weekend). Here's my code:
In this case, it's capturing 06/01/2008, but not 06/02/2008 - because 0602 is greater than 0531, it's staying at 0601. Any suggestions on what needs to be done so that I don't have to touch this thing again? I'm locked down so I can't even change the date on my calendar to test.
Thanks
Code:
NextMonth = DateAdd("m", 1, Form_frmMain.txtStart_Com) EndOfMonth = NextMonth - DatePart("d", NextMonth) strStart = Format(OfficeClosed(TheDate), "mmdd") 'OfficeClosed is another module that determines whether the date is a holiday strStart = Format(TheDate, "mmdd") strEnd = Format(Form_frmMain.txtEnd_Com, "mmdd") For counter = strStart To strEnd If counter > Format(EndOfMonth, "mmdd") Then counter = Format(DateAdd("d", 1, EndOfMonth), "mmdd") Else counter = Format(counter, "0000") End If 'text file is imported here Close #1 ' Close file. Next counter 'import next file
Thanks
Comment