Delete Tables VBA Code

Apr 10, 2007

Hi,

I'm trying to delete a table once I've used it and always get the same error saying that the table is already in use, these are the commands I've tried:

DB.TableDefs.Delete ("Report")

AND

strSQL = "DROP TABLE Report"
DB.Execute (strSQL)

Can't figure out how to avoid this. Please help

Mike

View Replies


ADVERTISEMENT

Can Delete Tables Via VBA Code In Runtime Environment

Apr 30, 2014

I am close to finishing a new database. In this database I have some VBA code that does a bunch of stuff, one of those things is to check if a temp table exists, and if yes then it will delete it.

Once finished this database will be made available to a range of people via Access Runtime 2010. I'm just wondering will the VBA code that deletes a table work in a Runtime environment?

I guess I should also ask if a save import process will also run via Runtime.just need to make sure that the users that need to do this code have full access if its required.

View 4 Replies View Related

Trying To Delete A Record With Code

Dec 11, 2005

Why does this code not delete the current record?

DoCmd.RunSQL "DELETE * FROM [Tble-Readings]WHERE
[Tble-Readings].[ID]= " & Me![ID] & ";"

I have this code on the a Close Button and if the record is incomplete I want it to be deleted from the table. The ID field is an autonumber so it is the 1st field to get a value if a user starts entering data. I get a msg box saying 0 fileds will be deleted why? the id's do match but it does not delete??

jon

View 5 Replies View Related

SQL Code To Delete Duplicate Records

Feb 19, 2013

I have a table that has 1335 records in, and columns names, Title, First Name, Surname, Address, Address2, Town/City, County, Postcode.I want to know how to write a SQL code, which will locate all the duplicates that match the First Name, Surname and Postcode and delete them, but keeping 1 copy of the duplicate.I have created a query to locate the duplicate records, and I have put the SQL code there. I tried changing this, however it would delete all the records, so I am not to sure what to try...

SELECT SurnameSearch.Title, SurnameSearch.[First Name], SurnameSearch.Surname, SurnameSearch.Address, SurnameSearch.Address2, SurnameSearch.[Town/City], SurnameSearch.County, SurnameSearch.Postcode
FROM SurnameSearch
WHERE (((SurnameSearch.[First Name]) In (SELECT [First Name] FROM [SurnameSearch] As Tmp GROUP BY [First Name],[Surname],[Postcode] HAVING Count(*)>1 And [Surname] = [SurnameSearch].[Surname] And [Postcode] = [SurnameSearch].[Postcode])))
ORDER BY SurnameSearch.[First Name], SurnameSearch.Surname, SurnameSearch.Postcode;

View 1 Replies View Related

How Can I Excute Code When The User End The MS Application By Alt+Ctrl+Delete

Aug 22, 2007

Some times, the system become stuck, which forces the user to end the program using Windows Alt+Ctrl+Delete. I have MS Access code which I want to execute when the user made the 'End Program' event using the Alt+Ctrl+Delete.

Thanks,

View 12 Replies View Related

Queries :: Delete Query Where Code And Client Are Equal

Aug 8, 2013

I am trying to delete a record in tblinclude where record from tblexclude are equal to clientid and codeid

Here is the sql
DELETE tblinclude.ClientID
FROM tblexclude INNER JOIN tblinclude ON (tblexclude.ClientID = tblinclude.ClientID) AND (tblexclude.CodeID = tblinclude.CodeID)
WHERE (((tblinclude.ClientID)=1));

I get the error Specify the table containing the records you want to delete. I've searched for this but I am just not getting it today.

View 1 Replies View Related

Delete Record Code Prevents Nested Events From Firing.

Apr 5, 2006

I need to give users the option to cancel a record they're creating. Whilst the delete code works fine, the following events in red no longer fire.


Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click

If MsgBox("Once YES is selected this cancel cannot be undone", vbQuestion + vbYesNo, "Are you sure you wish to cancel this entire record?") = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close acForm, "frmNewRec"
DoCmd.Close acForm, "frmSelectNew"
DoCmd.OpenForm "frmSwitchboard"

End If
Exit_cmdCancel_Click:
Exit Sub

Err_cmdCancel_Click:
MsgBox "Record deleted"
Resume Exit_cmdCancel_Click

End Sub

View 4 Replies View Related

Modules & VBA :: Code To Delete Table And Then Run 4 Append Queries To Refresh Data

Jun 11, 2014

I have a table called "EquipmentRequired" which is populated by 4 append queries,

5000BaseReq, 6000BaseReq, 6000IFBBReq, EquipmentReq which get some of their information by counting fields in another table but all have the same field names.

The queries contain all data that is initially used to append new records to the table and this works fine.Unless some information changes or a record is added then I would like to add a button to a form and call it "update equipment" behind which would run a vba code firstly to delete all the records in "EquipmentRequired" table then run the 4 queries without the warnings and re-populate the table.

View 9 Replies View Related

Tables :: Cascade Delete Not Being Enforced Between Tables

Nov 19, 2014

I'm a newb to Access and SQL and database management. I have a main table and a dependent table with a 1 to 1 relationship, relationship integrity and cascade update and delete. I used an append query after I had modified several records, and after the append deleted one of the records from the main table. It remained in the dependent table. Access didn't catch the disparity even after a restart. I broke the link and tried to reestablish it, and of course Access wouldn't let me. I deleted the record manually from the dependent table and all was well.

Why would referential integrity/cascade delete not be recognized after an append query?Access 2010.

This is the second time in two days that cascade delete has been broken in two days after using a query on the main table. Yesterday, after referential integrity was broken, deleting the records from the dependent table allowed me to restore Cascade Delete functionality and it worked for the rest of the day.

View 9 Replies View Related

Tables :: Delete A Record From Two Different Tables?

May 6, 2014

I have a form which contains many text boxes. What I'm doing now is that any time I create a new record I save this record to the table the form was created from and I also save to a specific field of an irrelevant table(other table) the index of one of the text boxes of this form.

e.g

My form contains the text boxes: "Index", "Tabletype", "Component".

I save all of the above to the table "tblTransistor".

Then I take the "Component" only and I save it in the field "Test" of another table which I call "tblManComps".

My form is called: "Transistor".

Now I want to be able to delete at the same time the record from each table.

Is it possible to have some VBA which will do it?

View 4 Replies View Related

Delete Tables

Mar 31, 2005

Is it possible to delete a table from a remote access db.
i.e
table "A" is in database "A"

from a form in database "B" i would like to run a routine that would
Delete table "A" from database "A"

i have tried using "DoCmd.DeleteObject acTable" but i think this only works for the currentdb
Can anybody help

Regards
Bjackson

I am using A2K

View 1 Replies View Related

Delete Two Tables

Nov 28, 2007

I have two different tables and I need to run a delete query to delete all information pertaining to an employee when he/she is expired threw a button on a continious form which uses one of the tables that needs deleted. How would I do this and please explain in newbie terms.....Thanks!

View 4 Replies View Related

Could Not Delete From Specified Tables

Feb 20, 2008

This seems like it would be a common problem but I tried to search for solutions to this and I haven't been able to find a specific answer. The forum excludes too many of the words I'm trying to use in my search....

I have two joined tables and I want a delete query to delete the specified records in the primary table and all of its related records in the secondary table.

DELETE tb_AccountHeader.*, tb_AccountDetail.* FROM tb_AccountHeader INNER JOIN tb_AccountDetail ON tb_AccountHeader.Index = tb_AccountDetail.Index WHERE tb_AccountHeader.PeriodStart=#1/1/2008#

This gives me the error "Could not delete from specified tables". I tried SELECT DISTINCTROW but that doesn't make a difference. I do not believe that it is an issue with permissions because I can delete records from either of these tables if I remove the join.

Any help would be appreciated.....thanks.

View 4 Replies View Related

Delete All Record From ALL Tables

Jun 15, 2006

Hi,

What's the SQL script for deleting all records in all tables, so without deleting the tables completely,

As I have over 50 tables I do not want to use:

"Delete from TableName"

Is there some wildcard I can use?

Thanks

View 7 Replies View Related

Insert And Delete Link Tables Using Vba

Jul 11, 2007

I have two table which is c:db1.mdb; c:db2.mdb

The user is currently using c:main.mdb
In main.mdb, I have a form, and have a combobox with two value, which is db1.mdb and db2.mdb.

If the user choose db2.mdb, delete all the current db1.mdb link tables(if there is any), and import all the tables from db2.mdb as link table
If the user choose db1.mdb, delete all the current db2.mdb link tables(if there is any), and import all the tables from db1.mdb as link table

And I need to perform some vba on the afterUpdate event of combobox.

My question is, how to
1)delete all link tables using vba
2)Import all tables from a certain mdb file as linked table using vba?

View 1 Replies View Related

Need To Delete Multiple Tables From One Form

Mar 22, 2008

Hi, I am designing a database for a basic payroll function. So far everything was going well until i started to design forms. I cannot delete multiple table entries from one table that connects two tables. This situation is as such:Employee Table: contains entries as follows:ID: Autonumber (PK)First Name Last Name PayCategory (Salary or Hourly) (List Box)PayInfo Table: contains entries as follows:ID: Autonumber (PK)Employee Name (Text)Pay RateThe relationship of these 2 tables is a one to many relationship; where the ID from Employee Table is connecting to Employee Name in PayInfo Table.When i created a form using these 2 tables and added a delete button to it, the entries from Payinfo table get deleted when i click the delete button, but not from the employee table.I have tried everything i can think of :( . What am i doing wrong? Can someone please guide me in the right direction. Any help would be greatly appreciated.

View 2 Replies View Related

NEWBIE HERE...Two Tables.. Want To Delete Duplicates Between Them

Apr 3, 2006

I think this is an easy one...

I have two tables - one is a Master. I want to delete the records in the Master if they are in the second table. Here's my SQL and I can't get it to work:

DELETE from TestMaster
INNER JOIN on JoinedDupList
ON TestMaster.ID=JoinedDupList.ID
WHERE JoinedDupList.ID = TestMaster.ID

I'm being told I need to define the table to delete from... I thought I defined it.

Thanks!

View 2 Replies View Related

Query Delete Few Tables Record

Feb 12, 2007

Hi,

Please, anyone know how to delete few table's record by using one query ?
I want to delete 10 tables, all the records inside at one times. I tried there is only one tables at a time. Is that imposible to do that?




shinyo

View 1 Replies View Related

Queries :: Could Not Delete From Specified Tables Error

Dec 17, 2013

I'm trying to delete data (no archiving required) from 5 tables that all have a one-to-many relationship between them and keep getting the following error: "Could not delete from specified tables".

I've tried everything I can think of including the following:

* Set unique records property to 'Yes'
* Enable referential integrity and cascade delete records in the relationship diagram
* Checked the DB isn't read only
* Have correct permissions to delete records

I'm the only person in the database but I'm at a loss and short of me actually deleting the 23891 records manually I can't think of what else to do!

View 5 Replies View Related

Tables :: Delete All Data From Field?

Dec 31, 2014

A database at our Food Pantry needs to be updated yearly on Jan. 1 by eliminating all data in two fields: "ID Check Date" (date field) and "Signature Obtained" (check box). There are hundreds of records. Is there a way to remove the data from the two fields (columns) while retaining the fields (and their formats) but with no data? We use Access 2010.

View 3 Replies View Related

Delete Fields In Tables By Using Sql Statement

Nov 14, 2012

I need to delete data in a table that named Cap One Table. I can not use a delete query since database located on company server and it is being used by many people. So, I have created a form and put on there two text boxes - txtStartDate and txtEndDate and command button cmdDelete. An idea behind this is that a user types date in txtStartDate and txtEndDate and click command button and delition happend in table Cap One based on that criteria. I put the below code in command button click event , but it doesn't work.

Dim startDate As String
Dim EndDate As String
Dim strSql As String
startDate = txtStartDate.Value
EndDate = txtEndtDate.Value

[code]....

View 4 Replies View Related

Cascading Delete Between Two Tables (1 To 1 Related)

Oct 17, 2014

I am not too clear about why it happens. See following diagram:

My TBLItemID table is having several 1-to-1 related tables

I have enforced referential integrity and checked off Cascade delete related records

When I remove a record from TBLItemID the same row will be deleted from every one of the related tables

Yet when I go into any of the related tables and remove a row, via the 1-to-1 relationship I would expect that it will propagate through the whole web and remove the same row from every table. However that is not true. It will only remove its own record without touching any one else's.

How is cascading delete supposed to work? Does it work only when we remove records from parent table?

View 1 Replies View Related

How To Delete Link Without Deleting The Tables

Aug 20, 2012

The tables in .mdb database are linked to a backend database. How do I delete the links, without deleting the tables?

View 3 Replies View Related

General :: Delete Button - Forms And Tables

Sep 12, 2012

I have a form, with tab control which includes fields from two tables. When I delete a record on a form it deletes fine.When I go into the tables the record is still there in the one side of the relationship but has been deleted in the table of the many side.

I've read that a simple delete button on a form will only delete records in the many side of a relationship from a table.How do I get a delete button that deletes the record from both the one and many tables.

View 10 Replies View Related

Queries :: Delete Query From Two Linked Tables

Jul 9, 2015

I have two linked tables (Unique_ID)

Table1 has a record of unique tasks.
Table2 has a list of people to do those tasks

They are linked by a Unique_ID (one to many - Table1 to Table2).Sometimes there can be an instance where there are Unique_ID's in Table2 but the reference Unique_ID is missing from Table1.

I have a select query that can show me these like so.

table2 table1
Unique_ID Unique_ID
Like * Not Like *

I can open the query and simply delete the records fine however i wish to automate this.What I want to do is delete the unrefenced Unique_ID's from table2.I have tried to just convert this select query into a delete query but it asks me which table I wish to delete and I cannot see where to enter this information.

View 3 Replies View Related

Queries :: Unmatched Records - Could Not Delete From Specified Tables

Jun 19, 2015

I was able to create a query that selects records from one table that have several fields which don't match with another table.

The end-game with this query is to have it delete the records in table 1 that don't match records in table 2. The delete query tells me that it could not delete from specified tables.

I've attached the select query, the delete query and the error, and the relationship table for the db.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved