Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting a table record from a form

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
0
0
GB
I have a continious form, based on a table (fd_inspector) - showing 2 fields "food inspector" and "delete" which is a yes/no field.
There is a command button "close" which when pressed I'd like the record in the table "food inspector" to be deleted, ONLY WHERE the "delete" field has been ticked (i.e. = yes)
I want to do this NOT using a query, so the user would have to click OK to confirm "data will be modified in the table (fd_inspector), I just want the user to tick, close and thats it! that food_inspector is deleted

Regards
Gwilym
 
You could do this two ways: on the 'on close' of the form, you could open a recordset and loop through it deleting the records where the delete field is set to yes:

dim rec as recordset
set rec = currentdb.openrecordset("fd_inspector", dbopendynaset)

do while not rec.eof
if rec!delete then
rec.delete
end if
rec.movenext
loop
rec.close
set rec = nothing

or you could use a delete query and disable the confirmation warnings given to the user:

DoCmd.SetWarnings False
DoCmd.OpenQuery "delete_records", acNormal, acEdit
DoCmd.SetWarnings True

Mike Rohde
rohdem@marshallengines.com
 
You could do this: on the event 'on close' of the form:

codeDB.Execute "DELETE * FROM fd_inspector WHERE delete"

My e-mail is: vzudaire@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top