Best way to check for deletion of data

G

Guest

I have two tables - one handles bookings by date largely for a defined group of members, but allows entries for guests. Combo boxes (Limit to list set to no) allow for the guests to be entered. If "guest" is entered a prompt to enter guest details through a second form and to a guests table occurs and the guests name appears in the main form/table. If the guest later cancels, deleting the booking from the main form is no problem, but I am looking for a way to sync the deletion of the named guest record from the main form with the guest table

How do I test for deletion of a named guest? How do I automate the deletion of guests table entry (which is name and date specific - ie: one guest could have multiple entries

Hope I have been clear enough

Thanks in advance for your time and help
 
W

Wayne Morgan

You could run an Unmatched Query to find records of this type that already
exist, then delete them. To set up an Unmatched Query, go to the database
window, queries tab. Click the New button, not the New query using wizard
line in the window, and choose the Unmatched Query wizard.

To handle this automatically in the future, use the form's Delete event to
check and see if the record being deleted is for a guest. If it is, the
prompt to confirm the delete. If the user says Yes, then run a delete query
on the other table to delete the associated records and then allow the
delete of the guest to continue. To avoid a second prompt for the delete,
you'll need to set a flag variable and cancel the prompt in the
BeforeDelConfirm event.

Another possibility, is that if the other table is used for guests only, you
may be able to use the Relationships window to set a link between the two
tables. Turn on Referential Integrity and Cascade Deletes in the link. This
will automatically delete the associated records when the guest is deleted.

--
Wayne Morgan
MS Access MVP


Bob Mullen said:
I have two tables - one handles bookings by date largely for a defined
group of members, but allows entries for guests. Combo boxes (Limit to list
set to no) allow for the guests to be entered. If "guest" is entered a
prompt to enter guest details through a second form and to a guests table
occurs and the guests name appears in the main form/table. If the guest
later cancels, deleting the booking from the main form is no problem, but I
am looking for a way to sync the deletion of the named guest record from the
main form with the guest table.
How do I test for deletion of a named guest? How do I automate the
deletion of guests table entry (which is name and date specific - ie: one
guest could have multiple entries)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top