S
SoggyCashew
Hello, I have a button on my form and in this buttons OnClick event I have
=ShowReport("L_iCalendar12") which opens the report L_iCalendar12 but only if
there is data selected in the function "ShowReport". All this works but I
needed to add a validation. I need to also check if there is data in a query
named qryYearView and if ther isnt then I need a mssgbox telling me and then
set focus to cboUser. I have no clue how to do this can someone help? Thanks!
Here is what I have:
Private Function ShowReport(ByVal RName As String)
If Me.cboDepartment.ListIndex = "-1" Then
MsgBox "You must make sure yor criteria's" & Chr(13) & _
"are selected in before proceeding." & Chr(13) & _
"" & Chr(13) & _
" - Please select a Department" & Chr(13) & _
" - Please select an Employee", vbCritical, "Selection Error"
Me.cboDepartment.SetFocus
Exit Function
End If
If Me.cboUser.ListIndex = "-1" Then
MsgBox "You must make sure yor criteria's" & Chr(13) & _
"are selected in before proceeding." & Chr(13) & _
"" & Chr(13) & _
" - Please select a Department" & Chr(13) & _
" - Please select an Employee", vbCritical, "Selection Error"
Me.cboUser.SetFocus
Exit Function
Else
DoCmd.OpenReport RName, acPreview
End If
End Function
=ShowReport("L_iCalendar12") which opens the report L_iCalendar12 but only if
there is data selected in the function "ShowReport". All this works but I
needed to add a validation. I need to also check if there is data in a query
named qryYearView and if ther isnt then I need a mssgbox telling me and then
set focus to cboUser. I have no clue how to do this can someone help? Thanks!
Here is what I have:
Private Function ShowReport(ByVal RName As String)
If Me.cboDepartment.ListIndex = "-1" Then
MsgBox "You must make sure yor criteria's" & Chr(13) & _
"are selected in before proceeding." & Chr(13) & _
"" & Chr(13) & _
" - Please select a Department" & Chr(13) & _
" - Please select an Employee", vbCritical, "Selection Error"
Me.cboDepartment.SetFocus
Exit Function
End If
If Me.cboUser.ListIndex = "-1" Then
MsgBox "You must make sure yor criteria's" & Chr(13) & _
"are selected in before proceeding." & Chr(13) & _
"" & Chr(13) & _
" - Please select a Department" & Chr(13) & _
" - Please select an Employee", vbCritical, "Selection Error"
Me.cboUser.SetFocus
Exit Function
Else
DoCmd.OpenReport RName, acPreview
End If
End Function