Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / May 2005

Tip: Looking for answers? Try searching our database.

Calculated Field Update Problem in SQL View

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Ayers - 25 May 2005 22:13 GMT
I have a form that uses a SQL view as the record source.  This view has a
calculated field "ExtPrice" which multiplies the "UnitPrice" by the
"QtyOrd".  When I update either the "UnitPrice" or the "QtyOrd" using the
form, the calculated field updates immediately.  This is how I want the
form to work...

However, this only works when the SQL view that I use as the record source
contains only one table.  I have a requirement to join two additional
tables in this view.  When I do this, the form still works but the
calculated field does not update automatically - only by refreshing the
form which is my current workaround.

Any thoughts on how to have the calculated field automatically update
without refreshing the form?

Thanks in advance!

Here is the view:

SELECT TOP 100 PERCENT dbo.tblSubcontractDetail.*,
dbo.tblSubcontractDetail.RorOtherUnitPrice +
dbo.tblSubcontractDetail.RorEvalUnitPrice +
dbo.tblSubcontractDetail.RorRepairUnitPrice AS RorUnitPrice,
(dbo.tblSubcontractDetail.RorOtherUnitPrice +
dbo.tblSubcontractDetail.RorEvalUnitPrice +
dbo.tblSubcontractDetail.RorRepairUnitPrice +
dbo.tblSubcontractDetail.UnitPrice) * dbo.tblSubcontractDetail.QtyOrd AS
ExtPrice

FROM dbo.tblSubcontractNameDetail INNER JOIN dbo.tblSubcontractName ON
dbo.tblSubcontractNameDetail.SubcontractNameID =
dbo.tblSubcontractName.SubcontractNameID INNER JOIN
dbo.tblSubcontractDetail INNER JOIN dbo.tblContractDetail ON
dbo.tblSubcontractDetail.ContractDetailID =
dbo.tblContractDetail.ContractDetailID ON
dbo.tblSubcontractNameDetail.SubcontractNameDetailID =
dbo.tblSubcontractDetail.SubcontractNameDetailID

WHERE dbo.tblSubcontractDetail.SubcontractNameDetailID IN (1413)

ORDER BY dbo.tblContractDetail.Clin, dbo.tblContractDetail.Elin,
dbo.tblSubcontractName.SubcontractName,
dbo.tblSubcontractNameDetail.SubcontractDeliveryOrder,
dbo.tblSubcontractDetail.Slin, dbo.tblSubcontractDetail.PartNumber,
dbo.tblSubcontractDetail.Description
Sylvain Lafontaine - 25 May 2005 22:35 GMT
You must create a resync command: first, write a stored procedure with one
parameter: the primary key for your main table (probably
tblSubcontractDetailId in your case) and returning only one record.  The
Select query is identical to your exemple with the exception that the WHERE
clause of this record is simply an equality based on tblSubcontractDetailId
and that you don't need the Order By, of course.

The property of the Resync command is simply the name of your resync stored
procedure followed by a single question mark:

My_ResyncQuery ?

I think that you must also set the Unique Table property but I'm not sure.
(Often, you cannot set the Unique Table property directly in the GUI when
the Record Source is a complex SP.  The solution is to change temporarily
the Record Source to the name of the table or to set this property in the
OnOpen event of the form.)

Signature

Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF

>I have a form that uses a SQL view as the record source.  This view has a
> calculated field "ExtPrice" which multiplies the "UnitPrice" by the
[quoted text clipped - 41 lines]
> dbo.tblSubcontractDetail.Slin, dbo.tblSubcontractDetail.PartNumber,
> dbo.tblSubcontractDetail.Description
Gary Ayers - 26 May 2005 14:12 GMT
Worked perfectly!  Thank you for the quick response.

Just to document...

The stored procedure I created was:

---
CREATE PROCEDURE dbo.spSubcontractDetailResync(@Param1 int)
AS

SELECT TOP 100 PERCENT dbo.tblSubcontractDetail.*,
dbo.tblSubcontractDetail.RorOtherUnitPrice +
dbo.tblSubcontractDetail.RorEvalUnitPrice +
bo.tblSubcontractDetail.RorRepairUnitPrice AS RorUnitPrice,
(dbo.tblSubcontractDetail.RorOtherUnitPrice +
dbo.tblSubcontractDetail.RorEvalUnitPrice +
dbo.tblSubcontractDetail.RorRepairUnitPrice +
dbo.tblSubcontractDetail.UnitPrice) * dbo.tblSubcontractDetail.QtyOrd AS
ExtPrice

FROM dbo.tblSubcontractNameDetail INNER JOIN
dbo.tblSubcontractName ON dbo.tblSubcontractNameDetail.SubcontractNameID =
dbo.tblSubcontractName.SubcontractNameID INNER JOIN
dbo.tblSubcontractDetail INNER JOIN
dbo.tblContractDetail ON dbo.tblSubcontractDetail.ContractDetailID =
dbo.tblContractDetail.ContractDetailID ON
dbo.tblSubcontractNameDetail.SubcontractNameDetailID =
dbo.tblSubcontractDetail.SubcontractNameDetailID

WHERE (dbo.tblSubcontractDetail.SubcontractDetailID = @Param1)

GO
---

The property of the Resync Command was:

---
spSubcontractDetailResync ?
---

The property of the Unique Table Command was:

---
tblSubcontractDetail
---
Vadim Rapp - 26 May 2005 06:22 GMT
Hello Gary,
You wrote in conference microsoft.public.access.adp.sqlserver  on Wed, 25
May 2005 21:13:49 GMT:

GAv> I have a form that uses a SQL view as the record source.  This view
GAv> has a calculated field "ExtPrice" which multiplies the "UnitPrice" by
GAv> the "QtyOrd".  When I update either the "UnitPrice" or the "QtyOrd"
GAv> using the form, the calculated field updates immediately.  This is how
GAv> I want the form to work...

GAv> However, this only works when the SQL view that I use as the record
GAv> source contains only one table.  I have a requirement to join two
GAv> additional tables in this view.  When I do this, the form still works
GAv> but the calculated field does not update automatically - only by
GAv> refreshing the form which is my current workaround.

I tried this with 3 trivial tables, but it worked ok, i.e. the calculated
field in the view was updated automatically.

When happens if you open the view in Access and do the update? does the
calculated field update?

If you still have the problem, please generate and post CREATE TABLE's for
your tables, and some sample data as INSERT.

Thanks,

Vadim Rapp
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.