Error Code

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have the following procedjure to delete a record from a listbox. The
problem is if nothing is selected in the listbox I get a generic error
message. How do I code it so that if nothing is selected in the listbox
I have my own form pop up.
Thanks
DS


Private Sub Command24_Click()
Dim myTax As String
myTax = "DELETE * FROM Tax " & _
"WHERE [TaxId] = " & Me![ListTax].Column(0) & ""
CurrentDb.Execute (myTax)
Me.ListTax.Requery
Me.Requery
End Sub
 
Private Sub Command24_Click()
Dim myTax As String

If Me![ListTax].ItemsSelected = 0 Then

' Nothing was selected: do whatever you need to

Else
myTax = "DELETE * FROM Tax " & _
"WHERE [TaxId] = " & Me![ListTax].Column(0) & ""
CurrentDb.Execute (myTax)
Me.ListTax.Requery
Me.Requery
End If
End Sub
 
Douglas said:
Private Sub Command24_Click()
Dim myTax As String

If Me![ListTax].ItemsSelected = 0 Then

' Nothing was selected: do whatever you need to

Else
myTax = "DELETE * FROM Tax " & _
"WHERE [TaxId] = " & Me![ListTax].Column(0) & ""
CurrentDb.Execute (myTax)
Me.ListTax.Requery
Me.Requery
End If
End Sub
Great! Thank you very much Douglas, just what I needed!
DS
 
Back
Top