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
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
Comment