hello i have a subform on my form, that are bound to a table. if a user clicks the "back" button, i do not want the record to be added to the table if there is a string anywhere in the subform textboxes. how would i go abotu this? thanks
hello i have a subform on my form, that are bound to a table. if a user clicks the "back" button, i do not want the record to be added to the table if there is a string anywhere in the subform textboxes. how would i go abotu this? thanks
It would seem to me that the record has already been added once they go off the record (click on a button). You will have to delete the record from the table. This should be simple enough as the current record will have the ID or PK so just run a query to delete it.
well the idea is i want the record automatically deleted if this button is clicked instead of manually removing it
There is no such thing as automatic - you have to program the button to do it for you. Either use VBA code or a macro to run a query which you have created - deleting the record where the pk = the pk on the form (the one just added).
What else does the back button do?
i have an add record button and a back button, the back button just goes back to the previous form, the add record button should add the record (its got a few queries tied to it). if user hits back button i dont want the record to be added (thats what the add record button is for)
i understand the record gets added prior to clicking on the button, but how do i program the back button to also remove the record? i dont have a delete or duplicate query wizard on my version of access. can you help me create a delete query if thats the only choice? thanks
Here is an example of a delete query. The "WHERE" condition will be set to something like WHERE primary-key-name = Forms!formname(!subformname)!primary-key-name. That way the query will delete the record that is current on you form, i.e. the one just added. (I hope you test these things before putting them into production!)
You can put this into the VBA code on the OnClick event of your back button - either make it a real query with a name and use DoCmd.OpenQuery "xxx" or you can use DoCmd.RunSQL "insert sql here......"
DELETE Table1.ID
FROM Table1
WHERE (((Table1.ID)=2));
thank you, that worked!