473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Select query that won't run as Update query?

Hello All,

Any reason why a select query that runs will not run as an update
query?

What I've done is created a select query that runs successfully. The
query has several custom functions to create data. When I attempt to
run the query as an update query I receive an error message which
reads:

'RetnCreateInvPd([tblInvCurYr]![ID],[tblInvCurYr]![PdNewOrd])' is not
a valid name. Make sure that it does not include invalid characters or
punctuation and that it is not too long.

The select query is below. Any ideals? TIA!

Select Query:

SELECT tblInvCurYr.ID,
RetnCreateInvPd([tblInvCurYr]![ID],[tblInvCurYr]![PdNewOrd]) AS
CalcInvPd, RetnRndInvNo([tblInvCurYr]![ID]) AS RdmInvNo,
RetnInvAmt([tblInvCurYr]![ID],[tblInvCurYr]![EstRev]) AS CalcInvAmt,
Round([CalcInvAmt]*ReturnRndCGSPerc([tblInvCurYr]![ID]),0) AS
CalcInvCGS FROM tblInvCurYr;

--
Regards,

Greg Strong
Nov 13 '05 #1
1 2603
On Fri, 23 Sep 2005 19:19:52 GMT, Greg Strong <NoJunk@NoJunk4UČ.com>
wrote:
Any ideals?


Yes run the whole thing in code calling the functions that I created.
It takes less than 25 seconds to update over 181k records.

Function SetUpInvData()

Randomize 'Initialize random number generator

Dim strInvPd As String
Dim lngInvNo As Long, lngID As Long, lngIDno As Long, lngInvAmt As
Long, _
lngInvCGS As Long

Dim dteStartTime As Date

Dim db As Database
Dim rstInvData As Recordset

Set db = CurrentDb()
Set rstInvData = db.OpenRecordset("tblInvCurYr", DB_OPEN_DYNASET)

'record start time
dteStartTime = Timer

rstInvData.MoveFirst
Do While Not rstInvData.EOF
'edit data
rstInvData.Edit

'set up invoice pd
lngID = rstInvData!ID
lngIDno = rstInvData!ID
strInvPd = rstInvData!PdNewOrd
strInvPd = RetnCreateInvPd(lngID, strInvPd)
rstInvData!InvPd = strInvPd

'set up invoice number
lngInvNo = RetnRndInvNo(lngID)
rstInvData!InvNo = lngInvNo

'set up invoice amount
lngInvAmt = rstInvData!EstRev
lngInvAmt = RetnInvAmt(lngIDno, lngInvAmt)
rstInvData!InvAmt = lngInvAmt

'set up invoice CGS
lngInvCGS = lngInvAmt * ReturnRndCGSPerc(CDbl(lngID))
rstInvData!InvCGS = lngInvCGS

'update data
rstInvData.Update

rstInvData.MoveNext
Loop

rstInvData.Close

MsgBox Format(Timer - dteStartTime, "00.00") & " seconds"

End Function
Sorry about any wrap!

--
Regards,

Greg Strong
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
4
by: dp | last post by:
After looking and looking, it appears that Access ADPs graphic query designer won't display: update customer set = . from customer, where customer. = .; It comes up with the "Query...
5
by: cdtsly | last post by:
Hi i have a table with all value at 4 i select all lines in a fetch i update one with a value of 7 i update all the row in the fetch with a value 5 the result is that all my row are at 5 and...
5
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
9
by: P3Eddie | last post by:
Hello all! I don't know if this can even be done, but I'm sure you will either help or suggest another avenue to accomplish the same. My problem may be a simple find duplicates / do something...
3
by: RAG2007 | last post by:
I'm using the QueryDef and Execute method to update a record in my MySQL backend. Problem: When the Passthrough update query is defined using QueryDef, it becomes a select query, and I cannot use...
5
by: Chris Cowles | last post by:
I use an application that uses Oracle 8.1.7. All functions of the application are completed with calls to stored procedures. A data entry error occurred that caused thousands of records to be...
2
by: DuncanIdaho | last post by:
Hi Apologies if this is similar to a (very) recent post. I was wondering if it is possible to execute an update query that contains a select statement on an MS access 2000 database. I have...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.