Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operation Must Use an Updateable Query 1

Status
Not open for further replies.

crystalreporting

Instructor
Feb 13, 2003
649
NZ
Hi,

I've developed this SQL statement and it runs fine in MS/SQL Query Analyzer;

Update OEORDHDR_SQL set OEORDHDR_SQL.tot_sls_amt = (Select SUM(Round(OEORDLIN_SQL.qty_to_ship * OEORDLIN_SQL.unit_price * ( 100 - OEORDLIN_SQL.discount_pct ) / 100,2 )) from OEORDLIN_SQL where OEORDHDR_SQL.ord_type = OEORDLIN_SQL.ord_type AND OEORDHDR_SQL.ord_no = OEORDLIN_SQL.ord_no AND OEORDHDR_SQL.selection_cd = 'S')

I'm now wanting this to run within an MSAccess application as part of a click event so I created this code;

'Recalculate the total sales amount based on the orders selected and the qty to ship
sql_statement = "Update dbo_OEORDHDR_SQL set dbo_OEORDHDR_SQL.tot_sls_amt =" & _
"(Select SUM(Round(dbo_OEORDLIN_SQL.qty_to_ship * dbo_OEORDLIN_SQL.unit_price * ( 100 - dbo_OEORDLIN_SQL.discount_pct ) / 100,2 )) " & _
"from dbo_OEORDLIN_SQL where dbo_OEORDHDR_SQL.ord_type = dbo_OEORDLIN_SQL.ord_type AND " & _
"dbo_OEORDHDR_SQL.ord_no = dbo_OEORDLIN_SQL.ord_no AND dbo_OEORDHDR_SQL.selection_cd = 'S')"
DoCmd.RunSQL (sql_statement)

I get a message that tells me the operation must use an updateable query. So I tried to do this as two separate queries (a select followed by an update) but I still get the same message.

Any ideas?

Peter Shirley
Macola Consultant, PA and surrounding states.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top