I have spent way too much time on this and really need help asap.
I have a table with dDate, AvgPrice and FXRate. I have another field "Factor" that is calculated based on the Weight value in th FactorTable table. I'm not sure how to call this query to run for a single record first of all.
Second, I have the query written in 3 places:
1. A SQL stored procedure (it works but I don't know the code to call it in Access)
2. I wrote it in query analyzer and it works.
3. I copied it into an Access query, and it tells me there is a syntax (missing operator) error. I also tried using VBA code, same error.
Here is the VBA code (same error as Access query):
If I just paste it into an Access query without the "From" statement, it prompts me for the dbo_FactorTable.Weight. If I add that table to the query, it tells me it needs an updateable query.
I'm so lost! Please help! Ideally I'd like the Sp to work, possibly in the after update method of the FX Rate, or maybe a trigger as someone suggested (although I don't know how to do this either).
This is a high priority project the owners require and I am so stuck, and our resourcs are very slim, and they won't hire any help for me. thank you.
I have a table with dDate, AvgPrice and FXRate. I have another field "Factor" that is calculated based on the Weight value in th FactorTable table. I'm not sure how to call this query to run for a single record first of all.
Second, I have the query written in 3 places:
1. A SQL stored procedure (it works but I don't know the code to call it in Access)
Code:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE [dbo].[SP_FactorCalc] AS
update DailyPrice set Factor =
((AvgPrice * FXRate * FactorTable.Weight)/ AvgPrice / FXRate)
from FactorTable where Factor is null
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
2. I wrote it in query analyzer and it works.
Code:
update DailyPrice set Factor =
((AvgPrice * FXRate * FactorTable.Weight)/ AvgPrice / FXRate) from FactorTable where Factor is null
3. I copied it into an Access query, and it tells me there is a syntax (missing operator) error. I also tried using VBA code, same error.
Here is the VBA code (same error as Access query):
Code:
Private Sub FXRate_AfterUpdate()
Dim strSQL As String
strSQL = "update dbo_DailyPrice set dbo_DailyPrice.Factor =
((AvgPrice * FXRate * dbo_FactorTable.Weight)/ AvgPrice / FXRate) from dbo_FactorTable WHERE (((dbo_DailyPrice.Factor) Is Null));"
Debug.Print strSQL
DoCmd.RunSQL strSQL
End Sub
If I just paste it into an Access query without the "From" statement, it prompts me for the dbo_FactorTable.Weight. If I add that table to the query, it tells me it needs an updateable query.
I'm so lost! Please help! Ideally I'd like the Sp to work, possibly in the after update method of the FX Rate, or maybe a trigger as someone suggested (although I don't know how to do this either).
This is a high priority project the owners require and I am so stuck, and our resourcs are very slim, and they won't hire any help for me. thank you.