Queries :: Can't Get Query To Even ALLOW To Update Record

Jul 1, 2015

I can do this in like 5 seconds in SQL Server but I can't get the query to even ALLOW me to update records.

Table1 - Columns
Query1 - ColumnDesc

Code:
SELECT DISTINCT C.Column
FROM Columns C INNER JOIN (
SELECT Cols.Column, Count(Cols.DataType)
FROM (SELECT DISTINCT Columns.Column, Columns.DataType FROM Columns) Cols
WHERE Cols.DataType = 'char' OR Cols.DataType = 'varchar'
GROUP BY Cols.Column
HAVING Count(Cols.DataType) > 1
) C2 ON C.Column = C2.Column;

Simple, straight forward query, that grabs all the rows from table Columns where there are more than one DataType per Column [name], and either one of those datatype strings are 'char' or 'varchar'.Now I want to UPDATE table Columns to set all of the columns whose "column" value is in the above query, and set all those DataType values to 'VarChar'. Thus I run that UPDATE query, and the above query should come back empty afterwords in SQL Server I would simply write:

Code:
UPDATE Columns
SET DataType = 'varchar'
WHERE EXISTS (
SELECT 1 FROM ColumnDesc INNER JOIN Columns ON ColumnDesc.COlumn = Columns.Column
)

And this would already have been done.But Access doesn't like that syntax. using the designer it created sql like this:

Code:
UPDATE Columns INNER JOIN ColumnDesc ON Columns.Column = ColumnDesc.Column
SET Columns.DataType = 'varchar'

But that wasn't an "Updateable" query.I have to run this on several patterns and right now I'm completely screwed if I can't get this to work.

My end goal is to have:
SELECT DISTINCT Columns.Column FROM Columns
return the same # of rows as
SELECT DISTINCT Columns.Column, Columns.DataType FROM Columns

for each duplication I will have to do different algorithm, but I can't even get one update query to work so I'm currently frustrated (and ready to reaffirm my belief that Access should have been discontinued 5 versions ago).

View Replies


ADVERTISEMENT

Queries :: Update Query Not Working On Last Record

Jun 26, 2014

I have this update query that is triggered by an after update event on a main form. The record being updated are in a continuous subform. It works well except from the last added/modified record. If I save and close the form and then open it again it works for all records but if modify or add a record, the update query will not work for that last modified/added record.

I have tried several things such as save record, use dirty = false for the on exit event of the subform control but nothing works. Here is the procedure:

Code:
Private Sub cboPoCurrency_AfterUpdate()
On Error GoTo ErrHandler
Dim db As Database
Dim strSql As String
Dim lngID As Long
Dim dblRate As Double
Set db = CurrentDb

[Code] ....

View 14 Replies View Related

Modules & VBA :: Running Update Query On Record And Have Form Show Updated Record

Jan 26, 2015

i want to be able to create an On Click Event when pushing a command button that will run an Update query to update a record and after it has been updated that specific record will pop up on a Form and be displayed. i know a different way is to run the Update query and then have it displayed in a Select query but i want it to be displayed on a Form instead. is it possible?

View 4 Replies View Related

Queries :: UPDATE Skips One Record

Aug 10, 2015

I have a query which reads a table, calculates some values and updates some of the table's fields. The issue that I have is that sometime (and randomly) the update skips one record. The query uses an inner join and looks as follows:

Code:
UPDATE TEMP4 AS t1 INNER JOIN TEMP4 AS t2
ON (t1.Month = DATEADD(""m"",1,t2.Month))
SET t1.index=(1+t1.ratio)* t2.index, t1.ratio = IIF( t2.index=0 ,t2.ratio, t2.index)

I can run the query multiple times without seeing any problem. When the issue occurs I do not receive any error.

I should also add that the query/update is run via VBA code. Not sure if this makes any difference.

Why this happen and how I can force the query to always update all records?

View 9 Replies View Related

Queries :: Update Number Of Record With Combolist

Mar 15, 2014

I want to create an update query to update 20 record with the first item in combolist then the next 20 record updated with the second item in list...

View 2 Replies View Related

How To Update All Queries When Enter A New Record In A Form

Jan 4, 2015

How can I update all the queries when I enter a new record in a form? When I enter a new employee record in a form, I want all the queries that are related to the employee information table to be updated with this new entry.

View 4 Replies View Related

Queries :: Update Or Insert / Append Record In Database

Jun 5, 2013

I have two tables "TABLEA" and "TEMP"

fields in both tables are
Cust ID (Primary key)
Cust Name
Address
Cheque No
Amount
Location
Zone

I need query when i click on command button on form

if "Cust ID" which is primary key in "TEMP" Table match with "Cust ID" from "TABLEA"

It will update the record in "TABLEA" if not then append the record

View 1 Replies View Related

Queries :: Update Newer Record With Older Fields

Apr 19, 2014

My table occasionally gets a second record added for the same person. What is the easiest way to update the new record with the non-zero fields from the older record, then delete the older record? There is a unique id field as well as a timestamp, so knowing which is older isn't a problem. Is there an easy way to do this?

View 2 Replies View Related

Queries :: Equipment Check In Form That Will Update One Record?

Mar 12, 2014

I have a transaction table the last record is [EquipIn]. during the equipment checkOut process all the other headings in the table are filled in. The idea is to fill in the [EquipIn] record a couple of days later when the equip is returned. How the heck can I make a equipment check in form that will update that one record? I can't do this manually as we have 1000+ pieces of equipment.

View 13 Replies View Related

Queries :: Update Field Based On Existing Record Fields

Jun 3, 2013

I have a field called uniqueID which I would like to update based on 2 other fields that are already populated in my recordset (from running previous queries). I heard it is not possible to do an Update Select like shown below.

select max(uniqueID) from myTable where a = "value of field a from first record in record set" and b = "value of field b from first record in record set"

If it is true that I cannot do an Update Select then I am trying to do something in VBA. How can I Loop each row in the record set and store the values from fields a and b. I would obviously then need to pass those values into the sql above and store the result in a variable. I would then do a straight update to put the value of uniqueID into myTable.

View 1 Replies View Related

General :: Update Record ID To Another Record ID In Same Table And Update Related Records

Aug 22, 2013

I have a table called tblCompanies. When a company acquires another company, I need a method by which the acquired company's CompanyID (PK) can be updated to the new company's CompanyID (PK). I also need to be able to update all related CompanyIDs (FKs) to the new value in related tables.

In cases in which the new company does not have an existing record, there is no problem: the company name simply gets changed to the new company and the existing CompanyID is maintained. I then use an audit table and Track Changes function to keep track of the company name data and a union query to keep the old names in the selection lists.

The problem is when both companies already have existing records in the table.

So, let's say I have records for Company A and Company B. Company A merges with Company B and Company B is now the main record. What is the best, simplest and easiest way to update the CompanyID (PK) from A to B and change the CompanyID (FK) to the new value in all related tables?

I am envisioning a pop-up form that directs the user to select the new company and then an update query happens behind the scenes... but exactly how does the criteria for the update query get selected and how do all the related tables get updated? My vba skills are pretty basic, will I need extensive coding to do something like this?

View 6 Replies View Related

Queries :: Auto Update One Table To Another Each Time New Record Added To Form

Jul 3, 2013

I am trying to automatically update one table to another each time a new record is added to my form, I have tried using the Update and the Append Query is there another way to do this without using code?

View 4 Replies View Related

Update A Record Without A Query?

Oct 31, 2007

Hi,

Don't know if this is possible, or if im being just plain stoopid:

Is there a vb command that will update a record without having to use a query?

My problem is this - I have an HR database which has allows us to add employees that are going to start. We then set their [Activity Status] from "Starting" to "Active". At the moment this is done manually, but what i would like to do is have this automatically change when the [Start Date] = Date().

The code i tried to use (but is obviously wrong) is:

If [Activity Status] = "starting" And [Start Date] < Date Then
Set [Activity Status] = "Active"
End Sub

Any thoughts what i might change "Set" to, to make this work?

Thanks,

Ferg.

View 6 Replies View Related

Can't Update Record From Select Query

Jul 30, 2006

Hi,

I have Access 2002 on Windows XP.

The last version of Access I've used was 97 but I'm getting back into it. I've read a couple of things that recommend creating a form based on a query, not a table, especially if a calculated field is involved.

When I create a select query based on 1 table, I can change/add/delete records right in the results of the select query, which will carry over to the form just fine.

However, when I use an additional table and join them in my select query, I can no longer update any of the fields that show in the query result. The link I'm using is just a 1 to 1.

How can I get around this? I'm using the second table just for lookup purposes (use the value of one of the fields in a calculation), but I want to be able to update the fields from table 1 from the form.

Thanks.

View 3 Replies View Related

Saving Record To Run Query & Update

Jun 14, 2005

Hi all,

I've got this form working ok but need to add some extra functionality but haven't a clue how to do it!

http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=10175

The uploaded database has two main forms. The first is used to enter customer data, the second runs from a query and shows all those records that have been completed in the first form (frmCustInfo - AgentLog = Yes) but not completed in the second form (frmControlsSource - AnalystLog = No)

Then more data is input into one of the subforms (frmControlChecks). Now in order for me to see the results of the queries connected to two other subforms I have to move off the record and back to it (for the record to be saved and then the queries run)

After moving back to the record, the query results on the right (Information Only) are manually added to the last subform 'Input Two', then the user would move on to the next record and do the same.
-------------------------------------------------------------------------------------------------------------
What I need it to do then is this: When the user tabs off the last field in the subform (frmControlChecks), the queries to the right (two subforms) would run, showing the results and also populating the last subform (frmAnalystInput)

The user would then click AnalystLog and move to the next record.

I hope this is possible without redoing the forms/queries because it's taken ages to get this far

I've also added info in this sample database and some working data if you want to take a look...thanks for any help

View 1 Replies View Related

Using Update Query To Change Record Value

Sep 12, 2007

I have a list of codes that need to be changed if it is part of the a list that need to be updated after being entered into the database. I created a function that holds the old values and what they need to be updated to. To get this accomplished on a form do I just need to write a Update query and then reference the query to the appropriate field I am trying to update with new codes for the 11 codes needing to be changed and leaving the other codes the same.

View 1 Replies View Related

Queries :: Update A Query Based On Results From Another Query Using Count Function

Apr 2, 2013

I run a physical therapy office and patients come in for treatment either 3, 4 or 5 times per week. My database is used to track these frequencies (among other things).

I have 3 queries which count how many patients come in 5, 4 and 3 times/week.

In my main table I have fields called "how many 5's", "how many 4's" and "how many 3's".

I have tried to design an update query which will update those fileds in my main table to reflect the counts in the 3 queries mentioned above.

(I'm not using SQL view, I'm using the query design view)

In the "update to:" row, I use the Build function and locate the count I'm looking for.

Problem: when I run the query I get the error: Operation must use an updateable query.

View 3 Replies View Related

Update Query Doesn't Select 1 Record

Nov 22, 2006

Upon closing my frmInventory the amount stock of stock is checked against a minimal stock value. If the stock amount is below a set minimal value a subsequent form is opened telling you that stock is low and an email message is generated to notify a manager. I have a checkbox on that form which is set to "True" upon close using an update query. The checkbox is there to give users the option to either send or not send a reminder message that stock is low when a message has already been sent earlier.

The problem is that using that update query ALL records are set to "sent=true" and not just the 1 record I intend.

This is my code in the "on close" event:

DoCmd.OpenQuery "qryUpdateEmailMinimal_True

and here's the SQL:

UPDATE tblInventory SET tblInventory.emailSentMinimal = True;


I assume what is missing is a reference to an inventoryID number. How do I do that?

View 3 Replies View Related

Update Query Creating Extra Record

Jan 5, 2005

i have this problem that is bugging the crud out of me:
sql="UPDATE bedrifter SET pr=" & Request.Form("pr") & ",totalindexedpages=" & Request.Form("tip") & ",totalinboundlinks=" & Request.Form("til") & ",description='" & Request.Form("dsc") & "' WHERE created='" & Request.Form("ts") & "'"

conn.Open connStr
conn.Execute(sql)
conn.close()
Set conn = nothing

when i run this code it updates the correct record (line in my access db) but then it also adds a new line with only that info in the update query. why is it doing this? when i update using the ID instead of using the timestamp in the WHERE clause it works fine. really frustrated...

View 1 Replies View Related

Error In Update Query: Record Is Deleted

Jul 16, 2007

While executing this query, I get this error code:

Record is deleted.

UPDATE [MDL-10] SET [MDL-10].[File Path] = "Download#\192.168.4.40h driveNTPC SIPATDMSSDocuments" & [ProjectNo] & "" & [Client Drg No] & ".pdf#"
WHERE ((([MDL-10].[REV 00 SUBMISSION]) Is Not Null));

I tried all but could not find any reason. Please help

View 3 Replies View Related

Update And Delete Query Of A Record By Date At The Same Time..

Oct 9, 2006

I have two tables. PreOrder and Order Tables. When our customer actually order a product, I want all information of that product to move from PreOrder table and append it to Order table. Currently, my user has to run an append query to add the record from PreOrder and add it to Order table. After that, she has to run a delete query to delete the record from PreOrder table. Since our query is setup to run by date, and order number..My user has to type the same thing twice. Is there anyone out there know the easy way? Thanks in advance..

View 1 Replies View Related

Modules & VBA :: SQL Update Query To Set A Record Field To Null?

Jul 11, 2013

On a push of a button from a form, I want to locate specific records within the table and update a field to Null if it matches a name

Dim strSQL As String
strSQL = "UPDATE tblmaster SET Score = "" WHERE [AdvocateName] = 'Anna Maria'"
DoCmd.RunSQL (strSQL)

I'm certain I don't have the syntax correct between the Set to Null and WHERE clauses..

View 4 Replies View Related

Queries :: How To Use Update Query

Aug 16, 2014

I am facing problem regarding updating of certain field of table. For example i would like to take data from a column of Table1 and would like insert that data into particular column in Table2.

Suppose Table One has data:

Table 1
ID Name amount
1 a 0
34 b 0
3 ab 0

Table2
ID Name amount
34 a 400
1 b 900
3 ab 4500

There are about 2000 records in each table.I would like to update column "Amount" of Table1 by taking data from Table2 "Amount" Field. how can i update the amount column by keeping the ID field?

View 5 Replies View Related

Queries :: Update Query To Add One To Current Value?

Dec 18, 2014

im working on an update query (written in VB coding) for one of my tables, for now im just setting the value to 1 (as currently all the data is set to 0, so for now it works), however id like to improve upon the query and get it to add 1 every time instead of setting it to 1 (i can work with it the way it is, but changing it would give me more info)

currently its at
DoCmd.RunSQL "UPDATE tblBatches SET tblBatches.batchCarryover = 1;"

View 1 Replies View Related

Queries :: Update Query From One Table To Another

Jul 2, 2014

I have 2 tables that hold similar data. In one table tblMultiSchedule I have a few blank columns. I want to update each column(ActualCost*) with the correct data which is stored in tblOrdersItems. the corresponding fields in each tbl are

tblMultiSchedule.OrderItemID1
tblOrdersItems.OrdersItemsID

I've been trying all day to have an update query to input the actual cost data into the tblMultiSchedule.

I know the rules regarding duplicate data but this is the only way i can do this.

View 4 Replies View Related

Queries :: Only A Certain Amounts Of Row With Update Query

Feb 14, 2014

possible to have an update query to only update 20 rows with a new data in the fields? And, how do I pass the information that I want to update only data from a certain date.If I have the word Cat and want to update it to Dog, but only with the dates 12-01-2014, where do I need to put the date part (also possible to do this for dates that are greater than 12-01-2014).

View 8 Replies View Related







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