Append And Delete Query Parameters Not Working In Macro

Jan 16, 2013

I've been creating a simple macro which will append data and then delete data from a table.The criteria for the queries is found in a form, and this is used as a paramter.However, when i run this all as a macro...the append and delete queries somehow can't read the criteria in the form. Rather...i have to type in the criteria again...and then it works.I have attached a copy of my DB.

1. Go to frmArchiveStock
2. Select a stock from the combo box (this the criteria for the append and delete queries)
3. Click the button to run macro mcrStockArchive.

How can i get the queries to pick up the value entered in the form to act as a criteria when they run?

View Replies


ADVERTISEMENT

Suppressing Dialog On Multiple Append And Delete Queries In A Macro

Aug 19, 2004

I have a macro setup that deletes all the records in 2 different tables, then using about 8 queries, appends several records to the two tables where data was deleted. When these macros run, several Yes/No/Cancel dialog boxes come up for each query, first asking you if you are sure you want to do this, that it is going to change data in my table, and then second telling me how many records it's going to append or delete.

Is there a way to make it automatically run Yes to all of these dialog boxes? That would really help out a whole lot. Of instead of that, but maybe some sort of VB code that could do all the deleting and appending without the need of the Macros, and that doesn't require user intervention. I have my Macro's setup on the "On Click" event in a form, so using VB would be no problem at all.

Any Suggestions?

View 10 Replies View Related

Append Query Not Working

Oct 28, 2004

I'm trying to append records from one table to another. The table I'm appending from was imported from an *.xls spreadsheet and now needs to be added to my primary table. Both tables have exactly the same field headings and data types. When I build the Append Query and try to run it, I first receive a pop up telling me the number of records that are going to be appended, when I click OK, I get an error.

Microsoft Access can't append all the records in the append query. Microsoft Access set 0 field(s) to Null due to a type conversation failure, and it didn't add 442 record(s) to the table due to key violations, 0 record(s) due to lock violations, and 0 record(s) due to validation rule violations.
Do you want to runt the action query anyway?
To ignore the error(s) and run the query, Click Yes,
For an explanation of the causes of the violations, click Help.

Can anyone help me??????

THIS IS SO CONFUSING.

View 3 Replies View Related

Append / Delete Query

Jul 26, 2007

I am trying to run a query that appends data into a table.. however, the way im setting it up.....lets say i have a table named Accouts, and under accounts there is #1 to 30. When I try to add a new account through a form, and append it to that, it takes the 31 there nwo are after i added one, and adds it to the 30 alraedy there, creating 61 instead of 31. is there anyway i can take into account for duplicates when im creating a query. im new to databasing, just got stuck with this assignment for the summer, and have no idea what im doing :( and i dont have time restart after learning normalization. i wish i did, but i dont. if it works it works, thats the bottom line. thanks everyone.

View 2 Replies View Related

Append And Delete Query

Jun 9, 2005

I have 2 databases which are mirror images of each other. one db is named rent and the other is named renthistory. in the db i have 2 tables, tblcustomer and tblradio. i would like a button on my form to append the current record to the renthistory db and then delete the current record. how can i do this?

Thanks in advance!
Tim

View 2 Replies View Related

Delete Query Not Working

May 12, 2005

Hi all,

I have a problem with a delete query i am trying to set up and hopefully one of you experts can help me out.

I have a table called [PMI] and a table called [Referrals]

The tables have a one to many relationship and are linked by the primary key field Patient_No.

I want to delete all records in [PMI] that have no records in [Referrals] and this is what i'm having problems with. I have created a select query where i can return the records i want to delete but its the removing of them from PMI that i cannot figure out.

Hope that makes sense, all help is greatly appreciated.

Thanks in advance.

View 4 Replies View Related

Delete Query Not Working

Mar 19, 2008

Hello All,

when I try and run the following query it says "please specify the table", and for some reason in the clause I cannot change the expression WHERE to FROM. Any ideas?

DELETE DISTINCTROW tbl_Table1.Date, tbl_Table1.Time, tbl_Table1.[SRC Extn], tbl_Table1.CLI2, tbl_Table1.[Dest Extn], tbl_Table1.Digits, tbl_Table1.Duration, tbl_ExcludeCLI.ExcludeCLI

FROM tbl_ExcludeCLI LEFT JOIN tbl_Table1 ON tbl_ExcludeCLI.ExcludeCLI = tbl_Table1.CLI2;

View 1 Replies View Related

Delete Results From Append Query

Jun 23, 2005

Sorry, I really couldn't think of a solid title for this. I'll try and explain and provide some code as well.

I've got a series of tables, one of which is linked to a Mobile Device. I have a query (herein called Query A) that queries a masterfile, named MasterFileEdit, based on selections the user makes on the front end. Query A then returns the results, sorted by section number. Query B is set up to query based on the same selections, but instead DELETE all of those records from the masterfile. Doing this makes sure that no duplicate work is performed.

Here's the code for Query A.
INSERT INTO [TABLE A1] ( OID, SystemLoc, SystemPN, Location, Part_Number, Qty, Date_n_Time, NL, RCHKL, RCHKP, oddeven, Auditor, upperlower, area, aisle, [section] )
SELECT TOP 100 MasterFileEdit.OID, MasterFileEdit.SystemLoc, MasterFileEdit.SystemPN, MasterFileEdit.Location, MasterFileEdit.Part_Number, MasterFileEdit.Qty, MasterFileEdit.Date_n_Time, MasterFileEdit.NL, MasterFileEdit.RCHKL, MasterFileEdit.RCHKP, MasterFileEdit.oddeven, MasterFileEdit.Auditor, MasterFileEdit.upperlower, MasterFileEdit.area, MasterFileEdit.aisle, MasterFileEdit.section
FROM MasterFileEdit
WHERE (((MasterFileEdit.oddeven) Like "*" & [Forms]![LocationAudit]![oddeven] & "*") AND ((MasterFileEdit.upperlower) Like "*" & [Forms]![LocationAudit]![upperlower]) AND ((MasterFileEdit.area) Like "*" & [Forms]![LocationAudit]![area]) AND ((MasterFileEdit.aisle) Like "*" & [Forms]![LocationAudit]![aisle]))
ORDER BY MasterFileEdit.section;

Everything after the 'FROM MasterFileEdit' after is the user selections that come from a form.

I need help writing the DELETE query. Here's what I've got thus far:

DELETE MasterFileEdit.OID, MasterFileEdit.SystemLoc, MasterFileEdit.SystemPN, MasterFileEdit.Location, MasterFileEdit.Part_Number, MasterFileEdit.Qty, MasterFileEdit.Date_n_Time, MasterFileEdit.NL, MasterFileEdit.RCHKL, MasterFileEdit.RCHKP, MasterFileEdit.oddeven, MasterFileEdit.Auditor, MasterFileEdit.upperlower, MasterFileEdit.area, MasterFileEdit.aisle, MasterFileEdit.section
FROM MasterFileEdit
WHERE (((MasterFileEdit.oddeven) Like "*" & [Forms]![LocationAudit]![oddeven] & "*") AND ((MasterFileEdit.upperlower) Like "*" & [Forms]![LocationAudit]![upperlower]) AND ((MasterFileEdit.area) Like "*" & [Forms]![LocationAudit]![area]) AND ((MasterFileEdit.aisle) Like "*" & [Forms]![LocationAudit]![aisle]));

I can't get the DELETE to sort. The query runs, but doesn't select the records it should. In fact, it doesn't select any of the correct records.

Thoughts: does the TOP 100 modifier work with Deletes?
Is this query even possible?

Thanks in Advance for your Help.

Matt

View 14 Replies View Related

Delete And Append Query At The Same Time

Feb 8, 2007

I don't know if this is the right place for my post. Since is in regard to queries...

I have data that I want to archive from one table to another table within a press of a button in a single form. The append work fine for me, but i tried adding the code to run the delete query to the same button as the append's one is, but giving me error that MS can't run the delete query because i have the form open exclusively. If I run the delete query with the form closed it work. How can I make the button to excute both append and delete queries at the same time.

Thanks in advance for the help

View 7 Replies View Related

Delete And Append Query At The Sametime

Feb 8, 2007

hey guys,

I'm new to this site, I have search a lot in this form regarding Delete and Append query used at the same time and couldn't find answer.

I have data that I want to archive from one table to another table within a press of a button in a single form. The append work fine for me, but i tried adding the code to run the delete query to the same button as the append's one is, but giving me error that MS can't run the delete query because i have the form open exclusively. If I run the delete query with the form closed it work. How can I make the button to excute both append and delete queries at the same time.

Thanks in advance for the help

View 1 Replies View Related

Delete Action Query Is Not Working.

Oct 29, 2004

This is a copy of the SQL statement used to update records from the tblContentImport Table to the tblContent Table.

UPDATE tblContent INNER JOIN tblConentImport ON (tblContent.Code = tblConentImport.Code) AND (tblContent.Type = tblConentImport.Type) AND (tblContent.Title = tblConentImport.Title) AND (tblContent.LoginName = tblConentImport.LoginName) SET tblContent.[Date Assigned] = [tblconentimport].[Date Assigned], tblContent.[Date Started] = [tblconentimport].[Date Started], tblContent.[Last Accessed] = [tblconentimport].[Last Accessed], tblContent.[Date Completed] = [tblconentimport].[Date Completed], tblContent.[Time Spent (min)] = [tblconentimport].[Time Spent (min)], tblContent.Score = [tblconentimport].[Score], tblContent.Result = [tblconentimport].[Result]
WHERE (((tblContent.LoginName)=[tblconentimport].[Loginname]) AND ((tblContent.Title)=[tblconentimport].[Title]) AND ((tblContent.Type)=[tblconentimport].[Type]) AND ((tblContent.Code)=[tblconentimport].[Code]));

Now I want to Delete these same records from the ContentImport Table. I change this statement to start with the word DELETE and Access want me to identify which table to delete the records from. What is wrong with my statement. Please help?

View 2 Replies View Related

Queries :: Press A Button And Run A Macro / Append Query To Add A Single Summary Record To Another Table

Aug 2, 2013

I have a query run that gives me a list of records that I view on a continuos form. What I want is to press a button and run a macro/Append Query to add a Single Summary record to another table.

For example my query spits out this data

Part # Quantity Serial Number
GO2 1 123
GO2 2 456
GO2 2 789

What I'm looking to get is

Part Number Total Quantity Serial Number 1 Serial Number 2 ..
GO2 5 123 456

I'm stuck on a couple of things.

1. Getting a new single row to append.
2. Getting Serial Numbers from several records to save on to a single record.

View 4 Replies View Related

Tables :: Append Query Not Working / Null Values?

Sep 24, 2014

I have an append query created to add files to a table from an imported excel file. The table to which I am appending (SubTBL) has a field names Observation. This field is not required. There is a relationship to another table (ObservationTBL) which has 3 records. The information I am trying to append includes 7000 records, about 4000 have observations assigned and they match the information in the ObservationTBL. The remaining 3000 have blank records for observation. When I run the append query, only those with observations are appended. The rest are not added because of "key violations". I removed the relationship between the ObservationTBL and the SubTBL and the append query runs. Then when I try to re-do the relationship it fails "Violates referential integrity rules".To be clear:

1. The records without an observation are blank. (There are other fields in this append that have blank fields also and they are not causing any problems)
2. The field observation is NOT set to required.

Is it not allowing Null records?

View 12 Replies View Related

Queries :: Append And Delete Query - Single Records

Mar 27, 2013

I am creating a database where the records of individual students are to be moved to different table depending on where they are in the graduation process. In order to do this, the secretary will enter the student in the "90 Hr Request" table (think of it as the first step), and move them down the line of tables (4 in total) until the final "Completed" table. Each table in the progression has more and more fields. However, a student (with their ID number as the primary key) can only be in one table at a time.

I understand this does not sound like a traditional database, as the data is not normalized. However, this is being used more as a filing system than anything else. Their data is primarily paper based (for legality reasons), but wishes to keep it organized in a database so they can run queries and print reports.

Currently, I am creating a macro that will run specific queries (in an order). I have made an append query that will move the records over, then I used a update (to null) and delete query combo to delete the old individual record. I made the delete + update query work by using a selected criteria.

How to make the append query move only one student's record at a time.

View 2 Replies View Related

No Warning Messge When Runing The Delete, Append Or Update Query!

Apr 11, 2007

why isn't my Access giving me warning before runing the delete, append or update query because usually it warns you that you are about to append, update or delete the following number of records. It must be the settings, can someone help!

View 9 Replies View Related

Queries :: Extract And Replace With Additional Data Append Delete Query

Jul 1, 2015

I have a Table1 served by Form1..It is a list of: UnqID, process, quantity, totaltime(in seconds).I want to click on a record to bring up a filtered Form2 with the chosen record on it.What I want to be able to do is to now split the quantity (and the time) and put these new records back into Table1 and delete the original record

EG

ID1,10,write a report,2400

I want to delete this and replace it with two (or three/four etc) replacements, but still adding up to 10 quantity and 2400 seconds so that the new data could be:

ID2,5,write a report,1200
ID3,5,write a report,1200

My initial thoughts are to create a holding table to:Append filtered data on Form2 to a holding Table1hld (i don't know how to do this) delete data in Table1.then enter the new quantities into a holding Table2 (that I will input myself) and then append (through a series of queries back into Table1).The first problem is how to append (and subsequently delete) the filtered record from Form2 to Table1hld.

View 1 Replies View Related

IN Clause Not Working With Parameters

Nov 2, 2005

Hi all: I am trying to filter a query based on user input from a ListBox. I loop thru the ListBox and build a comma-delimited list of IDs. It takes one parameter, but if there are 2 or more items in the list, it returns nothing. It's not the query, because if I hard code the same comma-delimited list into the SQL query ("...WHERE CategoryID IN (1,2,3)") it works fine.

This is the query:

SELECT tbl_Subsidiary.SubsidiaryName AS Brand, Sum(tbl_Placeview.Duration) AS SumOfDuration
FROM tbl_Subsidiary INNER JOIN tbl_Placeview ON tbl_Subsidiary.SubsidiaryID = tbl_Placeview.SubsidiaryID
WHERE (((tbl_Placeview.AirTime) Between [Forms]![frmTopBrandsByCategory]![txt_DateFrom] And [Forms]![frmTopBrandsByCategory]![txt_DateTo]) AND ((tbl_Placeview.CategoryID) In ([Forms]![frmTopBrandsByCategory]![txt_CategoryList])))
GROUP BY tbl_Subsidiary.SubsidiaryName
ORDER BY Sum(tbl_Placeview.Duration) DESC;

You can see I'm getting the list of "CategoryID" from a text field; after getting my comma-delimited list from the list box, I assign it to a hidden text field. In debug I can see that the list of IDs is built correctly.

Any ideas? I'm pulling out my hair over this!

Thanks in advance,
james

View 11 Replies View Related

General :: Key Value Violation With Macro Append From Spreadsheet

Mar 10, 2015

I am having problems with an append from a spreadsheet into a pre-populated table. I am using a macro to do this.

The table is in the middle of a hierarchy of tables. For example:

table 1 - Audit - key: AuditNumber & AuditName
table 2 - Process - key: AuditNumber & AuditName & ProcessRef
table 3 - Risk - key: AuditNumber & AuditName & ProcessRef & RiskRef
table 4 - Controls - key: AuditNumber & AuditName & ProcessRef & RiskRef & ControlRef
table 5 - Control tests - key: AuditNumber & AuditName & ProcessRef & RiskRef & ControlRef & TestRef

The front end of the database has a form for each table. Once you create an Audit in table 1 you can create multiple Processes underneath this one audit. Underneath a process you can create multiple Risks...... hence a hierarchy.

I am trying to append data to table 4 - controls. I have copied the format exactly into excel. I have also prepopulated the Audit, Process and Risk data in the required tables.

The reason I want this functionality is to enable team members to populate control information (oftentimes up to 25) in excel and then upload them easily into the database.

The macro I have created will work when created a new table. but when I point it at the existing table 4 - Controls I get the Key value violation error.

View 5 Replies View Related

Append/delete- It Has Been A While!

Dec 27, 2006

Hey everybody,

Admittingly I last did a query like this 4years ago and I know there is a simple way of doing it, but I have completely forgotten!

My problem: I am wanting to create a query which will automatically detect if a customer has NOT made an order in a period of twelve months (a customers details/orders are stored in the database: tables customer and tables order). Those who have not made any orders in 12months can be deleted (the option should be to delete them not automatic deletion.

I want the query to delete (if it is selected) all traces of that customer including their orders.

I tried creating the query and using the date function: <Date()-365, however, I want to make sure it will work.

Thanks and I hope people can help!

View 2 Replies View Related

Delete SQL Not Working?

Oct 24, 2007

Why does this sql not work?
It brings up the records which satisfy the criteria if one clicks on the view button. Yet does not delete the records! No warning signs appear at all

DELETE pupils.*, pupils.[Pupil ID]
FROM pupils
WHERE (((pupils.[Pupil ID])=[Forms]![Parents]![cmboPupilsDelete]));
Any ideas?
Thanks

View 10 Replies View Related

Delete Not Working

Oct 21, 2005

Hi All

I'm back with Access again for a short time (hurray) where I'm picking up a problem for one of Col's dbs. And I'm really stuck! :(

It's a car parking db and you go into the record from a form with a list box on.

There is a delete button, which has the usual wizard code behind it:

On Error GoTo Err_Delete_Click
Dim rsp As Variant

rsp = MsgBox("You will delete the entire record and associated permit and car details. Are you sure you want to do this?", vbQuestion + vbYesNo, "Warning!!!")

If rsp = vbYes Then

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Else

Exit Sub
End If

Exit_Delete_Click:
Exit Sub

Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click

Basically all this did was bring up the msgbox, bleep and not do anything else. When I debugged, it appeared to go through the code no problem.

I looked at an older db of mine and changed a few bits:

added docmd.setwarnings false and true before and after code
changed the Variant to Integer
Added docmd.close and requery of the form that the listbox is on, after the DoCmd. .... ... acVer70.

This closes the form, but doesn't appear to delete or requery, and when you click on the list box, there's now an error message, "No Current Record".

Anyone know what I'm doing wrong please.

Many thanks - Ally
I'm going now, but will be back on Monday.

View 14 Replies View Related

Delete All Rows Then Append

Oct 24, 2006

I need to append some rows into a table, before I add these rows i need to delete all of the old rows.

I can't use a Make Table query because I am updating a linked table in another database.

So how can I (automatically) delete all rows in that table before or during the append process.

Thanks
Steve

View 2 Replies View Related

Append/delete Queries

Sep 23, 2007

I got these two append and delete queries in my database that i want to run on startup. I was wondering if there is a way to not have the msg that pops up to ask if you are sure you want to append/delete 0 record to table if there isn't any record that matches the condition set. I'm sure there is a way because if there isn't any record that matches the condition set in the queries then i don't want to have to click "No" everytime the database starts.

thanks,
Vincent

View 14 Replies View Related

Queries :: Report Or Macro To Run Multiple Queries Using Same Parameters?

Aug 9, 2013

So I run cash flow for a business, and we export data from Oracle and insert it into an access database. I have to run about 25 queries, entering in the same parameters for each. We number each week of the year. So for say the first week in January, I would run the first query and it asks: Beginning Week, I enter in 1, then another paramter value asks me the ending week. I have to enter in these parameters for each of the 25 or so queries, and it becomes quite irritating. Each query has a number of columns, but I am only interested in obtaining the sum of one of the columns, titled Distribution amount. So I am looking for something that will run each of my specified queries, then spit out the total of the distribution column for each in a table like.

Query 1: Total Distribution
Query 2: Total Distribution
etc....

Is there anything that would allow me to do this, with entering in the week parameter once, say week 1 start, week 1 end. and it use those same parameters for each query?

View 1 Replies View Related

Complex Queries (Append/Update/Delete?)

Sep 4, 2005

I am accessing an oracle database that has several thousand records in it. I am quering for specific requirements, but would like to save my query results in a local access database for faster searching capabilities. Is there a way for me to set up a query that will go out to my oracle table files, select the records that pertain to my search criteria, and add records to locally stored tables without duplicating itself each time that I run the query? I would appreciate any assistance in this matter. Thanks for your help!

View 1 Replies View Related

How Do I Disable Append/delete/maketable Prompts?

Jul 19, 2006

I am basically making a form to streamline the processes and functionality of my database project, so basically it's just a form that runs queries.

However, whenever it runs an action query, it always brings up a yes or no prompt for whatever action it is doing. Is there any way to disable these prompts (i.e. default yes to everything) or is this just an annoyance I will have to deal with?

Thanks.

View 2 Replies View Related







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