This is driving me crazy. I have a listbox that is generated from the selection in a combo box on the same form (the listbox data is determined by the combo box value and After_update of the combo box refreshes the listbox. Here's the issue. If you highlight a record in the listbox and then change the combo box to a value that has no records in the listbox and highlight the "empty" value in the listbox and hit the delete button (code below) it deletes the record previously highlighted! Any ideas? I'm checking for null values which I would assume would be the empty listbox, but it's not working.
'Check for null value
If IsNull(Me!lstNotes) Then
MsgBox "There is no Note highlighted!"
Exit Sub
End If
'Delete the highlighted Note
DoCmd.RunSQL "DELETE * from tblNotes Where NoteID = " & Me.lstNotes & ";"
'Refresh the list
lstNotes.Requery
'Check for null value
If IsNull(Me!lstNotes) Then
MsgBox "There is no Note highlighted!"
Exit Sub
End If
'Delete the highlighted Note
DoCmd.RunSQL "DELETE * from tblNotes Where NoteID = " & Me.lstNotes & ";"
'Refresh the list
lstNotes.Requery