Hi all,
Basically my listbox lists the results of my query.
The list has 3 columns, 1. [Employee ID] 2. [ABN] 3. [Business Name]
Column 1 is hidden, and listbox is bound to column 2.
If the user makes a selection from that listbox, and clicks delete, things will delete as planned.
But there will be times when a user does not select from the list and click delete anyway.
The first two IF conditions of my code dont pick up a non (???) selection and just tells me that ZERO rows will be deleted from these two tables.
How can I fix these so that "Please make a selection" is displayed?
Basically my listbox lists the results of my query.
The list has 3 columns, 1. [Employee ID] 2. [ABN] 3. [Business Name]
Column 1 is hidden, and listbox is bound to column 2.
If the user makes a selection from that listbox, and clicks delete, things will delete as planned.
But there will be times when a user does not select from the list and click delete anyway.
The first two IF conditions of my code dont pick up a non (???) selection and just tells me that ZERO rows will be deleted from these two tables.
How can I fix these so that "Please make a selection" is displayed?
Code:
Set lstBusinessDetails = Forms("frmEditEmployee").Controls("lstBusinessDetails")
If IsNull(lstBusinessDetails.Value) Then
MsgBox "Please make a selection."
GoTo function_end
ElseIf lstBusinessDetails.Value = "" Then
MsgBox "Please make a selection."
GoTo function_end
Else
selection = lstBusinessDetails.Value
strSQL_delete = " DELETE * " & _
" FROM tblEmployeeBusiness " & _
" WHERE tblEmployeeBusiness.[ABN] = '" & selection & "' ; "
strSQL_delete2 = " DELETE * " & _
" FROM tblBusiness " & _
" WHERE tblBusiness.[ABN] = '" & selection & "' ; "
DoCmd.RunSQL strSQL_delete
DoCmd.RunSQL strSQL_delete2
vbaBusinessRequery
End If