Problem with Generating a schedule...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PerryC

    #1

    Problem with Generating a schedule...

    Experts,
    I encountered an "Type Mismatch" error when trying to run the
    following codes... What I wanted to do was to have the codes generate
    a 2 weeks schedule with just populating the date fields of a table and
    leaving the other fields with the same table blank or as is... then
    users can change the values of the other fields without having to fill
    in all the dates. Thanks in advance.

    ------------------------------------------------------------
    On Error GoTo OK_Click_Error

    Dim emp As Recordset
    Dim dblCurrentDate As Date
    Dim dblBeginDate As Date
    Dim dblEndDate As Date

    Dim lngResourceID As Long
    Dim strCriteria As String

    If Me![BeginDate] > Me![EndDate] Then
    MsgBox "End date cannot be less than begin date."
    DoCmd.GoToContr ol "BeginDate"
    Exit Sub
    End If

    DoCmd.Hourglass True

    dblBeginDate = Me![BeginDate]
    dblEndDate = Me![EndDate]
    dblCurrentDate = dblBeginDate

    Set dbs = CurrentDb()
    Set emp = dbs.OpenRecords et("Employees" , dbOpenDynaset)
    Set rstSchedule = dbs.OpenRecords et("WorkContent s", dbOpenDynaset)

    While (Not emp.EOF)
    emp.MoveNext
    lngResourceID = emp![EmployeeID]

    While dblCurrentDate <= dblEndDate
    rstSchedule.Add New
    rstSchedule![EmployeeID] = lngResourceID
    rstSchedule![WorkDate] = dblCurrentDate
    rstSchedule.Upd ate

    dblCurrentDate = dblCurrentDate + 1
    Wend
    Wend ' 1st while

    DoCmd.Close acForm, "Generate"
    rstSchedule.Clo se
    emp.Close
    dbs.Close

    OK_Click_Exit:
    DoCmd.Hourglass False
    Exit Sub

    OK_Click_Error:
    MsgBox Err.Description
    Resume OK_Click_Exit
    End Sub
    ------------------------------------------------------------------

    Sincerely,
    Perry
  • Bob Quintal

    #2
    Re: Problem with Generating a schedule...

    perryche@yahoo. com (PerryC) wrote in
    news:ea92818f.0 405170731.7e892 a41@posting.goo gle.com:
    [color=blue]
    > Experts,
    > I encountered an "Type Mismatch" error when trying to run
    > the
    > following codes... What I wanted to do was to have the codes
    > generate a 2 weeks schedule with just populating the date
    > fields of a table and leaving the other fields with the same
    > table blank or as is... then users can change the values of
    > the other fields without having to fill in all the dates.
    > Thanks in advance.
    >[/color]

    Temporarily comment out the On Error Goto statement and use the
    debugger to show you where your error is.

    I suspect that it's the use of doubles instead of dates. (A
    datetime record is a type of double, but Access treats them
    separately).


    Bob Quintal


    [color=blue]
    > ------------------------------------------------------------
    > On Error GoTo OK_Click_Error
    >
    > Dim emp As Recordset
    > Dim dblCurrentDate As Date
    > Dim dblBeginDate As Date
    > Dim dblEndDate As Date
    >
    > Dim lngResourceID As Long
    > Dim strCriteria As String
    >
    > If Me![BeginDate] > Me![EndDate] Then
    > MsgBox "End date cannot be less than begin date."
    > DoCmd.GoToContr ol "BeginDate"
    > Exit Sub
    > End If
    >
    > DoCmd.Hourglass True
    >
    > dblBeginDate = Me![BeginDate]
    > dblEndDate = Me![EndDate]
    > dblCurrentDate = dblBeginDate
    >
    > Set dbs = CurrentDb()
    > Set emp = dbs.OpenRecords et("Employees" , dbOpenDynaset)
    > Set rstSchedule = dbs.OpenRecords et("WorkContent s",
    > dbOpenDynaset)
    >
    > While (Not emp.EOF)
    > emp.MoveNext
    > lngResourceID = emp![EmployeeID]
    >
    > While dblCurrentDate <= dblEndDate
    > rstSchedule.Add New
    > rstSchedule![EmployeeID] = lngResourceID
    > rstSchedule![WorkDate] = dblCurrentDate
    > rstSchedule.Upd ate
    >
    > dblCurrentDate = dblCurrentDate + 1
    > Wend
    > Wend ' 1st while
    >
    > DoCmd.Close acForm, "Generate"
    > rstSchedule.Clo se
    > emp.Close
    > dbs.Close
    >
    > OK_Click_Exit:
    > DoCmd.Hourglass False
    > Exit Sub
    >
    > OK_Click_Error:
    > MsgBox Err.Description
    > Resume OK_Click_Exit
    > End Sub
    > ---------------------------------------------------------------
    > ---
    >
    > Sincerely,
    > Perry
    >[/color]

    Comment

    Working...