MS Access coding help matching data and deletion from two linked tables

Posted on 2002-04-12
Last Modified: 2013-11-27
I have built an access database that uses forms. I am having trouble with trying to delete a piece of data.
The project is a car parking system and in the main screen is portrayed the registration number. when this is clicked a form (car edit form)appears to enable the car details to be changed with the registration number locked ie. not able to be edited but appears on the screen. To sell the car a button is clicked to produce the customer entry form and then the customer details are taken and then the form is closed.
I want to be able to take the registration number from the car edit form and delete it from two linked table the first of which is the space table and the next is the cars table. How do I do this?
Question by:Lyndonbatchelor

Accepted Solution

kcm76 earned 150 total points
ID: 6937922
this may help u
have u given cascade delete records in referential integrity, u just delete the record in master table.
like delete * from master_table where registration_number = " & CLng(txtregistration.text)

otherwise, u have to delete it from the detail table first.

delete *
from detail_table, master_table
where detail_table.ForeignKeyField = master_table.PrimaryKeyField and master_table.registration_number = " & Clng(txtregistration.text)

for deleting in the master table, as mentioned earlier,

delete * from master_table where registration_number = " & CLng(txtregistration.text)


LVL 16

Expert Comment

ID: 7755019

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to kcm76
Please leave any comments here within the
next seven days.

Expert Comment

ID: 7812395
per recommendation

Community Support Moderator @Experts Exchange

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now