Hi all,
I have created a form that is used to select a date for reporting purposes. The user selects the date from a datetimepicker and then the date is passed to a stored procedure to be saved in a sql server. After the date is inserted the form is closed and disposed off. However, after the form closes and before my reports are printed I get the following error:
Here is the code for the datetimepicker event:
Any help would be greatly appreciated! Thanks,
jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
I have created a form that is used to select a date for reporting purposes. The user selects the date from a datetimepicker and then the date is passed to a stored procedure to be saved in a sql server. After the date is inserted the form is closed and disposed off. However, after the form closes and before my reports are printed I get the following error:
Code:
Cannot access a disposed object.
Object name: 'DateTimePicker'.
System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'DateTimePicker'."
Source="System.Windows.Forms"
ObjectName="DateTimePicker"
...
Here is the code for the datetimepicker event:
Code:
Call ClearTable(Servername)
Call InsertSelectedDate(Servername)
Me.Focus()
If MsgBox("You have selected " & Me.DateTimePicker1.Value & " as the report date." & vbCrLf & "Is this correct?", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "Confirm Date") = MsgBoxResult.No Then
Exit Sub
End If
Try
Me.Close()
Me.Dispose()
Catch ex As Exception
MsgBox("Error: " & Err.Number & vbCrLf & "Desc: " & Err.Description)
End Try
Any help would be greatly appreciated! Thanks,
jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations