Deleing fields in a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (Insurance Companies) and a subform (Insurance Company
Contacts). The subform has many contacts. I am trying to create a button in
my Insurance Companies form that will delete the current field in the
subform. Any suggestions?
 
hi,

Christian > said:
I have a form (Insurance Companies) and a subform (Insurance Company
Contacts). The subform has many contacts. I am trying to create a button in
my Insurance Companies form that will delete the current field in the
subform. Any suggestions?
If you want to delete the current record (dataset) in your subform, then
the following should work:

Private Sub cmdDeleteContact_Click()

CurrentDb.Execute "DELETE FROM Contacts WHERE ID = " & _
sfInsuranceCompanyContacts.Form![ID]
sfInsuranceCompanyContacts.Form.Requery

End Sub

If you don't have an unique identifier, you need to change the condition
to match the primary key fields in your contacts table.


mfG
--> stefan <--
 
Correction, that should be deleting records in a subform. I want to be able
to delete a contact at the click of the button.
 
I have a form (Insurance Companies) and a subform (Insurance Company
Contacts). The subform has many contacts. I am trying to create a button in
my Insurance Companies form that will delete the current field in the
subform. Any suggestions?

Use the Command Button tool on the toolbox, with the magic wand icon
selected. Choose the option to create a button which deletes a record.
It's simplest if the button is *on the subform*, rather than on the
mainform; when a command button has the focus on the mainform, it's
ambiguous WHICH record on the subform you mean.


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top