访问表单 - 通过链接表上的连接从查询编辑记录

时间:2014-03-06 11:44:32

标签: sql sql-server ms-access linked-tables

我的设置是将带有链接表的Access 2000用于SQL 2008服务器。

我创建了一个表单,显示来自单个链接表的数据,该表与数据库中的视图的1个字段连接(请参阅下面的SQL)。表和视图之间的关系是1:1,为什么这不应该导致问题。但是,我体验到我无法通过表单更新记录集中的记录。尝试在其中一个字段中写入时,我收到错误消息“Recordset无法更新”。

根据http://rogersaccessblog.blogspot.dk/2009/11/this-recordset-is-not-updateable-why.html,有很多问题,但我会说我遵守了不能更新记录集的规则。

我看到它使用相同的设置,所以我很困惑为什么它现在锁定记录集。

这是我的SQL查询:

    SELECT dbo_Balance.*, 
[dbo_Amount_summary_all_specifications].[SUM_AMOUNT] AS Specification
    FROM dbo_Amount_summary_all_specifications 
RIGHT JOIN dbo_Balance ON 
([dbo_Amount_summary_all_specifications].[Version]=[dbo_Balance].[Version]) AND
([dbo_Amount_summary_all_specifications].[Year]=[dbo_Balance].[Year]) AND
([dbo_Amount_summary_all_specifications].[Period]=[dbo_Balance].[Period]) AND
([dbo_Amount_summary_all_specifications].[Kardex]=[dbo_Balance].[Kardex]) AND
([dbo_Amount_summary_all_specifications].[Account]=[dbo_Balance].[Account])

WHERE [dbo_balance].[Balance]<>0;

提前谢谢!

更新2014-03-12

我的SQL数据库中的数据来源:

CREATE VIEW [dbo].[VW_Overview_balance]
AS SELECT TOP (100) PERCENT dbo.Balance.ID, dbo.Balance.Year, dbo.Balance.Period,
dbo.Balance.Version, dbo.Balance.Kardex, dbo.Balance.Account, dbo.Balance.Kardex_name,
dbo.Balance.Kardex_code, dbo.Balance.Kardex_hierarki, dbo.Balance.Coop_franchise,
dbo.Balance.Chain, dbo.Balance.Chain_name, dbo.Balance.Responsible, 
dbo.Balance.Balance, dbo.Balance.Comment, dbo.Balance.Bank_account, 
dbo.Balance.Approver, dbo.Balance.Timestamp, dbo.VW_specifications_bank.SUM_AMOUNT_bank,
dbo.VW_specifications_system.SUM_AMOUNT_system,dbo.VW_specifications_erp.SUM_AMOUNT_erp, 
dbo.VW_specifications_user.SUM_AMOUNT_user, dbo.SUM_Total_Balance.Tot_Balance, - 
ISNULL(dbo.Balance.Bank_account, 0) - ISNULL(dbo.VW_specifications_erp.SUM_AMOUNT_erp, 0) 
+ ISNULL(dbo.VW_specifications_bank.SUM_AMOUNT_bank, 0) - 
ISNULL(dbo.VW_specifications_system.SUM_AMOUNT_system, 0) - 
ISNULL(dbo.VW_specifications_user.SUM_AMOUNT_user, 0) AS Specification, 
dbo.SUM_Total_Balance.Tot_Balance - ISNULL(dbo.Balance.Bank_account, 0) - 
ISNULL(dbo.VW_specifications_erp.SUM_AMOUNT_erp, 0)  +
ISNULL(dbo.VW_specifications_bank.SUM_AMOUNT_bank, 0) -
ISNULL(dbo.VW_specifications_system.SUM_AMOUNT_system, 0)  -
ISNULL(dbo.VW_specifications_user.SUM_AMOUNT_user, 0) AS Difference, dbo.Account.Account_name

FROM dbo.Balance LEFT OUTER JOIN dbo.Account ON 
dbo.Balance.Account = dbo.Account.Account_no LEFT OUTER JOIN dbo.SUM_Total_Balance 
ON dbo.Balance.ID = dbo.SUM_Total_Balance.ID LEFT OUTER JOIN dbo.VW_specifications_bank 
ON dbo.VW_specifications_bank.Balance_id = dbo.Balance.ID LEFT OUTER JOIN dbo.VW_specifications_erp 
ON dbo.VW_specifications_erp.Balance_id = dbo.Balance.ID LEFT OUTER JOIN dbo.VW_specifications_system 
ON dbo.VW_specifications_system.Balance_id = dbo.Balance.ID LEFT OUTER JOIN dbo.VW_specifications_user
ON dbo.VW_specifications_user.Balance_id = dbo.Balance.ID

WHERE     (dbo.Balance.Kardex_code <> 3) 
AND (dbo.Balance.Kardex_code <> 13) 
AND (dbo.SUM_Total_Balance.Tot_Balance <> 0) 
AND (dbo.Balance.Account IN
(SELECT Account_no FROM dbo.Account AS Account_1))

Access数据库中的查询已减少为:

SELECT dbo_VW_Overview_balance.Kardex, dbo_VW_Overview_balance.Account,
dbo_VW_Overview_balance.Kardex_name, dbo_VW_Overview_balance.Kardex_hierarki,
dbo_VW_Overview_balance.Coop_franchise, dbo_VW_Overview_balance.Chain_name,
dbo_VW_Overview_balance.Responsible, dbo_VW_Overview_balance.Comment,
dbo_VW_Overview_balance.Approver, dbo_VW_Overview_balance.Tot_Balance,
dbo_VW_Overview_balance.Specification, dbo_VW_Overview_balance.Difference,
dbo_VW_Overview_balance.Year, dbo_VW_Overview_balance.Period,
dbo_VW_Overview_balance.Version, dbo_VW_Overview_balance.Account_name

FROM dbo_VW_Overview_balance

ORDER BY dbo_VW_Overview_balance.Kardex, dbo_VW_Overview_balance.Account;

1 个答案:

答案 0 :(得分:0)

support.microsoft.com/KB/304179的帮助下,我找到了一个解决方案:虽然我在SQL数据库上有主键,但我还没有在Access的链表中配置它。通过更新链接表并手动分配主键,我现在可以通过查询和表单更新记录集!