ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I am using the code below.
I start to type a name in Textbox1 & the results starts to appear in the listbox.
My first issue & may be more but at present unable to get past this step.
I select a customers name & i see a message Do i wish to delete this customer.
Yes should delete the customer & i should then get the confirmation message, customer is deleted but no confirmation message.
No should stop the process & selct TextBox 1, BUt i see customer has been deleted message followed by customer was not delete message, customer wasnt delete but i see the messages appear
I start to type a name in Textbox1 & the results starts to appear in the listbox.
My first issue & may be more but at present unable to get past this step.
I select a customers name & i see a message Do i wish to delete this customer.
Yes should delete the customer & i should then get the confirmation message, customer is deleted but no confirmation message.
No should stop the process & selct TextBox 1, BUt i see customer has been deleted message followed by customer was not delete message, customer wasnt delete but i see the messages appear
Rich (BB code):
Private Sub ListBox1_Click()
Dim answer As Integer
Range("A" & ListBox1.List(ListBox1.ListIndex, 1)).Select
Dim c As Range
With Sheets("DETAILS")
Set c = .Range("A:A").Find(What:=ListBox1.Value, _
After:=.Range("A5"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
If Not c Is Nothing Then
If MsgBox("ARE YOU SURE YOU WISH TO DELETE CUSTOMER " & ListBox1.Text & "?", vbYesNo + vbInformation, "DELETE CUSTOMER FROM DATABASE") = vbYes Then
Rows(c.Row).EntireRow.Delete
Else:
TextBox1.Value = ""
TextBox1.SetFocus
MsgBox "THE CUSTOMER " & Me.ListBox1.Value & " HAS NOW BEEN DELETED" & vbNewLine & "DELETE ANOTHER CUSTOMER ? ", vbYesNo + vbInformation, "CUSTOMER DELETED MESSAGE"
If Result = vbYes Then
TextBox1.Value = ""
Else:
Unload DeleteCustomer
Range("A3").Select
Unload DeleteCustomer
MsgBox "THE CUSTOMER " & Me.ListBox1.Value & " WAS NOT DELETED", vbInformation, "CUSTOMER WAS NOT DELETED MEAASGE"
Range("A3").Select
End If
Set c = Nothing
End If
End If
End Sub