
Originally Posted by
vbasicgirl
You need to run UpdateBoldedDates after any changes
MonthCalendar1.UpdateBoldedDates()
Casey.
Hi I am having a problem with my code. Everytime I pass through this line
Code:
mocScheduler.UpdateBoldedDates()
An error message occurs like this:
Code:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Operation is not valid due to the current state of the object.
If there is a handler for this exception, the program may be safely continued.
Here is the complete code:
Code:
Dim vstrChoice2 As String
If chkWaitingForResponse.Checked = True Then
vstrChoice2 = "SELECT Format(Date_Planned, 'MM/dd/yyyy') FROM (ACTIONS LEFT JOIN NEEDS ON ACTIONS.Need_ID = NEEDS.Need_ID) LEFT JOIN PERSONAL_DETAILS ON NEEDS.Client_ID = PERSONAL_DETAILS.Personal_DetailID WHERE Month(Date_Planned) = Month(#" & lblCalendar.Text & "#) AND Year(Date_Planned) = Year(#" & lblCalendar.Text & "#) AND PERSONAL_DETAILS.Income <> '6-STANDBY' AND ACTIONS.Date_Executed IS NULL GROUP BY Format(Date_Planned, 'MM/dd/yyyy')" & _
" UNION " & _
"SELECT Format(Date_Executed, 'MM/dd/yyyy') FROM (ACTIONS LEFT JOIN NEEDS ON ACTIONS.Need_ID = NEEDS.Need_ID) LEFT JOIN PERSONAL_DETAILS ON NEEDS.Client_ID = PERSONAL_DETAILS.Personal_DetailID WHERE Month(Date_Executed) = Month(#" & lblCalendar.Text & "#) AND Year(Date_Executed) = Year(#" & lblCalendar.Text & "#) AND PERSONAL_DETAILS.Income <> '6-STANDBY' AND ACTIONS.Client_Response = '[Waiting For Response]' GROUP BY Format(Date_Executed, 'MM/dd/yyyy')"
Else
vstrChoice2 = "SELECT Format(Date_Planned, 'MM/dd/yyyy') FROM (ACTIONS LEFT JOIN NEEDS ON ACTIONS.Need_ID = NEEDS.Need_ID) LEFT JOIN PERSONAL_DETAILS ON NEEDS.Client_ID = PERSONAL_DETAILS.Personal_DetailID WHERE Month(Date_Planned) = Month(#" & lblCalendar.Text & "#) AND Year(Date_Planned) = Year(#" & lblCalendar.Text & "#) AND PERSONAL_DETAILS.Income <> '6-STANDBY' AND ACTIONS.Date_Executed IS NULL GROUP BY Format(Date_Planned, 'MM/dd/yyyy')"
End If
Dim da2 As New OleDb.OleDbDataAdapter(vstrChoice2, cnn)
Dim dt2 As New DataTable
da2.Fill(dt2)
mocScheduler.RemoveAllBoldedDates()
If dt2.Rows.Count > 0 Then
For i As Long = 0 To dt2.Rows.Count - 1
Call ADDBOLD(Year(dt2.Rows(i).Item(0)), Month(dt2.Rows(i).Item(0)), DatePart(DateInterval.Day, dt2.Rows(i).Item(0)))
Next
End If
mocScheduler.UpdateBoldedDates()
Please help me. I am no a programmer but I am self studying how to be one.