Chris Mackin
chris at denverdb.com
Fri Feb 7 15:37:06 CST 2003
Not the Date he was talking about, the line: If myReportDate = rs![Date] Then references the Date field in the table tblHoliday, Date should not be used as a fieldname. That being said you should modify your code to either add a rs.movelast to get the proper recordcount AND modify your loop to For i = 0 To rs.RecordCount - 1 OR what I'd suggest is open your tblHoliday recordset with the SQL: "SELECT * FROM tblHoliday WHERE ([Date] = #" & myReportDate & "#)" then just test to see if you get any records, if you do then it's a holiday, if not then not, saves a lot of looping and unneeded processing. Chris Mackin www.denverdb.com Denver Database Consulting, LLC -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of Oleg_123 at xuppa.com Sent: Friday, February 07, 2003 2:22 PM To: accessd at databaseadvisors.com Subject: RE: [AccessD] rs.recordcount Charles "date" is not a field, its gives me todays date - 1 (2/6/03) > Oleg, > > Two things. 1. What is the error you are getting? We are not > mindreaders. 2. "Date" is a reserved word and should not be a field > name of your recordset. > > Charles Wortz > Software Development Division > Texas Education Agency > 1701 N. Congress Ave > Austin, TX 78701-1494 > 512-463-9493 > CWortz at tea.state.tx.us > (SELECT * FROM users WHERE clue > 0) > > > -----Original Message----- > From: Oleg_123 at xuppa.com [mailto:Oleg_123 at xuppa.com] > Sent: Friday 2003 Feb 07 14:53 > To: accessd at databaseadvisors.com > Subject: [AccessD] rs.recordcount > > I am checking when was the last working day - here's what I got -- > > > Private Function CheckCurrentDate() > Dim dbs As Database, rs As DAO.Recordset, i As Integer > myReportDate = IIf((Weekday(Date - 1) = vbSunday), Date - 3, > IIf((Date > - 1) = vbSaturday, Date - 2, Date - 1)) > 'Checks if the last business day was equal a holiday > > Set dbs = CurrentDb > Set rs = dbs.OpenRecordset("tblHoliday") > > For i = 1 To rs.RecordCount 'Counts total records in tblHoliday > If myReportDate = rs![Date] Then > > myReportDate = IIf(Weekday(myReportDate - 1) = vbSunday, > (myReportDate - 3), _ > IIf(Weekday(myReportDate - 1) = vbSaturday, > (myReportDate > - 2), (myReportDate - 1))) > > Exit Function > End If > rs.MoveNext > Next i > rs.Close > End Function > > ---------------------------- > > > For i = 1 To rs.RecordCount 'Counts total records in tblHoliday > If myReportDate = rs![Date] Then > > this line is giving me an error; why is it ? i thought that it is > correct synthaxis (i had to change to " For i = 1 To 10 " for know... > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com ----------------------------------------- Send a Xuppa Valentine to Your Sweetheart today! http://www.xuppa.com/greet/ _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com