Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2004, 10:01 PM
Authorized User
 
Join Date: Aug 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default Append & Delete Query

There are probably people who have already seen similar questions from me before, but I am beginning to get frustrated with this. I am still trying to append information from one table to another then delete the appended information from the original table. I am using a delete query and an append query to do this. The trouble I am having is I have a form with a combo box. The combo box has a query data source that accesses 2 tables(which are part of a many to many relationship). When I click on the combo box and select the printer and the system it is located on, I hit a button which is supposed to delete the selected printer and the system it is located on. For example:


PrinterID SystemID Bldg# Model Type
JD234D H010 234 RJS Label


When I select this in the combo box, how do I get the append query to move only that record to my deleted table and the delete query to delete only that record from the source table. Every time I do it it will delete that printer ID and all of the systems it is located on which is not what I want it to do. There is some VBA code that I am using for the delete button and I know that is the key. I am really frustrated.


 
Old October 7th, 2004, 03:31 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Try adding this code to your on-click event on the form
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

    DoCmd.RunSQL ("Delete * from <printer table> where PrinterID = " & printerID & ";")
    Me.<printer table>.Requery
    Me.Requery
    Me.Refresh

Exit_cmdDelete_Click:
    Exit Sub

Err_cmdDelete_Click:
    MsgBox Err.Description
    Resume Exit_cmdDelete_Click

End Sub


I hope this helps

Jaime E. Maccou
Applications Analyst
 
Old October 7th, 2004, 03:40 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Please see correction

Try adding this code to your on-click event on the form
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

    DoCmd.RunSQL ("Delete * from <printer table> where PrinterID = " & printerID & ";")
    Me.<printer table>.Requery
    Me.Requery
    Me.Refresh

Exit_cmdDelete_Click:
    Exit Sub

Err_cmdDelete_Click:
    MsgBox Err.Description
    Resume Exit_cmdDelete_Click

End Sub


I hope this helps

Jaime E. Maccou
Applications Analyst


--------------------------------------------------------------------------------
Edited by - jemacc on 10/07/2004 04:32:33 AM


Jaime E. Maccou
Applications Analyst





Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
Append Query bright_mulenga Access 1 January 3rd, 2007 01:33 PM
Append Query Cybersurfer Access 1 February 13th, 2006 01:02 PM
Make Table & Append Querys lryckman Access 1 January 25th, 2006 05:38 PM
append query stoneman Access 2 November 12th, 2003 09:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.