Hi I have a form on which I have fields from one table like id, name, second name etc.
To get to that form I use button with following code:
Code:
DoCmd.Close acForm, "Dostawcy_główny"
DoCmd.OpenForm ("Dostawcy_nowy")
DoCmd.GoToRecord , , acNewRec
It is closing current form, open new one to write new record to table but I want to be able to cancel operation of enetering new client.
But when I enter for example 2 fields of 10 needed and close form record; is being saved to table anyways with missing fields.
I would like to be able to cancel entering and to not save record so I made this code:
Code:
Private Sub Anuluj_Click()
Dim final As String
Dim data As String
data = id_dostawcy.Value
final = "DELETE * FROM Dostawcy WHERE id_dostawcy = " & data & ";"
DoCmd.RunSQL final
DoCmd.Close
DoCmd.OpenForm "Dostawcy_główny"
End Sub
id_dostawcy = text field with id of client.
Dostwacy = desired table
Code compiles but always says: "Do You awnt to delete 0 records?"
EDIT: Solved, You need to first Close Form.