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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Record from two tables 1

Status
Not open for further replies.

hotcoals

Technical User
Jul 12, 2006
7
AU
Hi I have a database that has two tables in it. One table has all of the data in it, when someone searches the table for information it appends the appropriate records to the second table to view on a seperate form. My question is how do i delete a record from both tables? I can delete it from one but not both. The commands i am using are:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
 
Sounds like an odd setup but you could use something like this BEFORE the code above

Code:
docmd.setwarnings false
docmd.runsql ("DELETE tbl1.* FROM tbl1 WHERE [YourPrimaryKey]=" & me!YourprimaryKey)
docmd.setwarnings true

JB
 
Are you new to Access? Reason I ask is that your design violates some protocols of Access. Have you read:
Fundamentals of Relational Database Design

You don't have the same data in two tables. Why aren't you using a query to just filter the table?

Access has alot of non-intuitive concepts to it. One is normalization. Extremely important.
 
Thanks for the reply. fneily the reason I have designed it like that is because when i run a select query to grab the appropriate data and view it on a form the query window pops up in the backgroud and i don't know how to stop it.
 
Hot,

Possibly look at setting the filter on the form when the user searches?

JB
 
Is your query in the Record Source of your form? Or are you running code where you run the query first then assign it to the record source? If code, before you run the query, put
DoCmd.Echo False
DoCmd.SetWarnings False

Then at the end of the code, change them to True.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top