Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete recprd from combo list

Status
Not open for further replies.

skaurd

Technical User
Jun 4, 2002
51
0
0
GB
Hi

I have a combo list with all the records from a table.

I also have a delete query with a parameter to enter a company.

is there a way to incorporate the 2? So that when the record is selected from the combo list, it goes off and deletes it from the table?

But also gives several warning messages before?

many thanks

S
 
Put logic to run your delete query in the Before Update event for the combo box in question. That should do it.

The reason I said in Before Update instead of After Update is because Before Update includes a Cancel parameter. If you set it to True and exit sub then it will return control to the combo box without deleting the customer if the user quits out of the delete process.

Good Luck!

PS. Test thoroughly on test data ;-)
 
sorry, what logic exactly?

thanks

S
 
Assume you have a combobox named cboCustomerList and you have a delete query named qryDeleteCustomer. In the properties box for cboCustomerList select the Before Update event on the Events tab and set it to event procedure. This will generate an empty sub for you to work with.

Put code similar to the following in the Before_Update
procedure:

Private Sub cboCustomerList_BeforeUpdate(Cancel As Integer)

If vbYes = Msgbox("Do you want to delete the selected" _
& " customer", vbYesNo + vbQuestion) Then
do anything you need to before deleting the cust
run qryDeleteCustomer here
do anything else after the fact
Else
Cancel = True 'this will return contrl to the combo
Exit Sub
End If

End Sub
 
Assume you have a combobox named cboCustomerList and you have a delete query named qryDeleteCustomer. In the properties box for cboCustomerList select the Before Update event on the Events tab and set it to event procedure. This will generate an empty sub for you to work with.

Put code similar to the following in the Before_Update
procedure:

Private Sub cboCustomerList_BeforeUpdate(Cancel As Integer)

If vbYes = Msgbox("Do you want to delete the selected" _
& " customer", vbYesNo + vbQuestion) Then
do anything you need to before deleting the cust
run qryDeleteCustomer here
you can pass cboCustomerList as a parameter to
your delete query if it returns the primary
key that you need
do anything else after the fact
Else
Cancel = True 'this will return contrl to the combo
Exit Sub
End If

End Sub

Good Luck
 
SBendBuckBye

How would this relate to the Delete query only deleting the specified selection from the combo list?

Can you help me with that?

thanx

S
 
My email address is in my profile. Send me an email and I will try to help you with some working code.

Good Luck!
 
Sorry SBendBuckeye, but call me stupid, but I cannot find your email address in your profile.

thanx

S
 
Sorry, I don't know what happened to it. Home is landgwiney@characterlink.net. I'll look for it when I get home tonight or if you post yours I can maybe catch it over lunch at work.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top