I am using Access97 front-end for an application.
SQL Server 2000 for the back-end of the application.
(ODBC remote linked tables)
i have the update (after) trigger on one sql table, and all
works fine when manually changing the row to the specified
criteria... trigger fires.. and email sends...
the problem is that when clicking the approve button
in the application under conditions that the trigger would fire i get a 'ODBC error - update on remote table failed'. and the update query that access97 sent seemed to abort.
any ideas how to fix ? thanks.
trigger code:
CREATE TRIGGER selfapproval1000 ON [dbo].[tblPOlog]
AFTER UPDATE
AS
--IF APPROVED_BY DIDNT CHANGE THEN EXIT
if not update(approved_by)
begin
return
end
--DETERMINE IF PO WAS SELF-APPROVED AND REACHES LIMIT OF $1000
IF EXISTS (SELECT * FROM INSERTED WHERE APPROVED_BY = INITIATED_BY AND TOTAL >= 1000 )
BEGIN
--EMAIL CODE
DECLARE @EMAILMESSAGE VARCHAR(255), @LOC VARCHAR(2), @PO varchar(10), @USER VARCHAR(40), @VENDOR VARCHAR(50), @LINK VARCHAR(255)
--SET VARIABLE VALUES
SELECT @LOC = LOCID, @PO = PONUMBER, @USER = APPROVED_BY, @VENDOR = VENDOR_NAME
FROM INSERTED
WHERE APPROVED_BY = INITIATED_BY AND TOTAL >= 1000
--BUILD LINK
SELECT @LINK = ' + @PO
--BUILD MESSAGE
SELECT @EMAILMESSAGE = 'CPO Notification ! PO Number ' + @LOC + '-' + @PO +' has just been self-approved by ' + @USER + ' to ' + @VENDOR + '. To view this po click the following link: ' + @LINK
--SEND EMAIL
EXEC master..xp_sendmail @recipients = 'hidden@us.hidden.com', @message = @EMAILMESSAGE, @subject = 'CPO Controller - Self-Approval of PO over $1000'
END
SQL Server 2000 for the back-end of the application.
(ODBC remote linked tables)
i have the update (after) trigger on one sql table, and all
works fine when manually changing the row to the specified
criteria... trigger fires.. and email sends...
the problem is that when clicking the approve button
in the application under conditions that the trigger would fire i get a 'ODBC error - update on remote table failed'. and the update query that access97 sent seemed to abort.
any ideas how to fix ? thanks.
trigger code:
CREATE TRIGGER selfapproval1000 ON [dbo].[tblPOlog]
AFTER UPDATE
AS
--IF APPROVED_BY DIDNT CHANGE THEN EXIT
if not update(approved_by)
begin
return
end
--DETERMINE IF PO WAS SELF-APPROVED AND REACHES LIMIT OF $1000
IF EXISTS (SELECT * FROM INSERTED WHERE APPROVED_BY = INITIATED_BY AND TOTAL >= 1000 )
BEGIN
--EMAIL CODE
DECLARE @EMAILMESSAGE VARCHAR(255), @LOC VARCHAR(2), @PO varchar(10), @USER VARCHAR(40), @VENDOR VARCHAR(50), @LINK VARCHAR(255)
--SET VARIABLE VALUES
SELECT @LOC = LOCID, @PO = PONUMBER, @USER = APPROVED_BY, @VENDOR = VENDOR_NAME
FROM INSERTED
WHERE APPROVED_BY = INITIATED_BY AND TOTAL >= 1000
--BUILD LINK
SELECT @LINK = ' + @PO
--BUILD MESSAGE
SELECT @EMAILMESSAGE = 'CPO Notification ! PO Number ' + @LOC + '-' + @PO +' has just been self-approved by ' + @USER + ' to ' + @VENDOR + '. To view this po click the following link: ' + @LINK
--SEND EMAIL
EXEC master..xp_sendmail @recipients = 'hidden@us.hidden.com', @message = @EMAILMESSAGE, @subject = 'CPO Controller - Self-Approval of PO over $1000'
END