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

Manipulating dates 2

Status
Not open for further replies.

santastefano

Programmer
Aug 9, 2005
54
IT
I have a loop which creates a timetable based on user input of the first date and the frequency.
Code:
Do While varSessionsTotal > 0
   With rsTimeTable
      .AddNew   'Creates new record in the table
      !Code = varCode
      !StartDate = varStartDate
      !From = varTime1
      !To = varTime2
      .Update   'Confirms the record to the table.
   End With
   varSessionsTotal = varSessionsTotal - 1
   varStsrtDate = varStartDate + 7
Loop
I need to refer varStartDate to a list of user maintained holidays before looping back to avoid bookings during holidays. I have tried
Code:
Dim strCriteria As Date
Dim rsHolidays As DAO.Recordset
    Set DB = CurrentDb
    Set rsHolidays = DB.OpenRecordset("tblHolidays", dbopendynaset)
    strCriteria = varStartDate
    With rsHolidays
    .FindFirst strCriteria
    End With
and receive an error message for the .Find instruction

I have tried opening a query based on the holiday table and user input and checking for an empty record set - empty meaning OK, some content meaning add 7 days.

I have tried adapting various date solutions posted here without success.

Can anybody please be a sheepdog and round me up and point me in the right direction?

If you got to here, thanks for reading.
George
 
It'sd a typo here, sorry!
The code is OK and works without the breakout to check against a holiday table.
 
strCriteria = "[name of date field in tblHolidays]=#" & Format(varStartDate, "yyyy-mm-dd") & "#"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
As PHV said.

FindFirst method, DAO or Find ADO, requires a WHERE statement, without the "WHERE".


strCountry = "Canada"
.FindFirst "txtCountry ='" & strCountry & "'"

dteChristmas = #12/25/06#
.FindFirst "txtHoliday =#" & dteChristmas & "#"

.FindFirst "txtScore = 45
 
Thank you very much Zion7 and PHV.
This is a successful fix!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top