I am using a list box for our scheduling database in which the "Days Off" are selected for an employee. What happens is if for some reason nothing is selected you get an error saying:
"Invalid call or procedure"
What I would like to do is have a msgbox pop up if nothing is selected so the person knows that they forgot to select the days off without them having to wonder what the "Invalid call or procedure" error is. this is what im using:
Private Sub Command51_Click()
On Error GoTo Err_Command51_Click
Dim stDocName As String
Dim ctl As Control
Dim varItm As Variant
Dim myStr As String
Dim strSQL As String
Set ctl = DaysOffSelect
For Each varItm In ctl.ItemsSelected
myStr = myStr & ctl.ItemData(varItm) & ","
ctl.Selected(varItm) = False
Next varItm
myStr = Left(myStr, Len(myStr) - 1)
Me.DaysOffSelect = myStr
I tried adding something like :
If IsNull(varItm) Then MsgBox ("You must enter the employee's days off to save this record.")
but it didnt pop up before the error.. any ideas? TIA
"Invalid call or procedure"
What I would like to do is have a msgbox pop up if nothing is selected so the person knows that they forgot to select the days off without them having to wonder what the "Invalid call or procedure" error is. this is what im using:
Private Sub Command51_Click()
On Error GoTo Err_Command51_Click
Dim stDocName As String
Dim ctl As Control
Dim varItm As Variant
Dim myStr As String
Dim strSQL As String
Set ctl = DaysOffSelect
For Each varItm In ctl.ItemsSelected
myStr = myStr & ctl.ItemData(varItm) & ","
ctl.Selected(varItm) = False
Next varItm
myStr = Left(myStr, Len(myStr) - 1)
Me.DaysOffSelect = myStr
I tried adding something like :
If IsNull(varItm) Then MsgBox ("You must enter the employee's days off to save this record.")
but it didnt pop up before the error.. any ideas? TIA