delete current record after subform is closed

  • Thread starter Thread starter AngiW
  • Start date Start date
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!
 
---------- [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
 
---------- [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
 
Back
Top