×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

deleting a table record from a form

deleting a table record from a form

deleting a table record from a form

(OP)
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
Replies continue below

Recommended for you

RE: deleting a table record from a form

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

RE: deleting a table record from a form

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close