delete current record after subform is closed

A

AngiW

Ok...here it goes!

I have a main form and an error form. If the person presses Cancel on the
error form, I want to delete the current main form record. How do I do I do
that? I can get it to delete the error form's current record, but not the main
form's. TIA!
 
E

Emilia Maxim

---------- [email protected] (AngiW) said:
I have a main form and an error form. If the person presses Cancel on the
error form, I want to delete the current main form record. How do I do I do
that? I can get it to delete the error form's current record, but not the main
form's. TIA!

Angi,

is the error form a subform on the main form or a popup form?

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
E

Emilia Maxim

---------- [email protected] (AngiW) said:
it's a pop up. Sorry for the delay in answering!

Angi,

assuming the main form is open when the user klicks Cancel, you would
need something like this in the button's OnClick event procedure:

Dim strWhere As String
Dim strSQL As String

' WHERE clause to select the record displayed
' in the main form
strWhere = "[NameOfPrimaryKeyField] =" &
Forms![MyMainForm]![NameOfPrimaryKeyTextBox]

' Now put together the DELETE statement
' using the above WHERE clause
strSQL = "DELETE * FROM [MyTable] WHERE " & strWhere

' Run the Delete statement
CurrentDB.Execute strSQL, dbFailOnError

Post back if you need further help.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 

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

Top