数据输入表单在先前记录的大多数列中显示#error [英] data entry forms show #error in most columns of a previous record

查看:89
本文介绍了数据输入表单在先前记录的大多数列中显示#error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行良好的2010 MS Access应用程序,直到将其导入MS Access2013.现在,在插入新记录时,所有数据输入表单在上一条记录的大多数列中均显示#Error.窗体使用ADODB.Recordsets. #Error会一直保留,直到单击要还原为原始数据的每个字段为止.

I have a 2010 MS Access Application that ran fine until importing into MS Access 2013. Now all the data entry forms show #Error in most columns of a previous record when inserting a new record. The Forms use ADODB.Recordsets. The #Error persists until clicking on each field where it reverts to original data.

在供应商更新新记录之前

Before Vendor Update of a New Record

RowID    Vendor    Ticket
1        DUFFERIN  12345
2        LAFARGE   54321
3        MILTON

供应商更新后

RowID    Vendor    Ticket
1        DUFFERIN  12345
3        #ERROR    #ERROR
3        MILTON    123

我的连接字符串:

ConnectADO = "Data Provider=SQLOLEDB.1" & _
";Data Source=" & TMServerName & _
";Initial Catalog=" & TMDatabaseName & _
";Persist Security Info=False " & _
";user id=" & TMUserName & _
";password=" & TMPassword

Cn.Provider = "MSDataShape"
Cn.CommandTimeout = 120
Cn.ConnectionString = ConnectADO
Cn.Open

我的光标设置

Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.CursorLocation = adUseClient
rs.LockType = LockType
rs.ActiveConnection = Cn
rs.Open Sql

推荐答案

我终于明白了.

如果在插入表单时ADO活动连接处于打开状态,则会发生#Error行为.如果连接已关闭,则一切正常.插入和更新仍然发生.因此,请尽快关闭连接.我这样做是这样的(Cnn.RecordsetOpen函数是自定义的,并且在ADODB记录集open语句之前有一个connection.open语句).

If the ADO Active Connection is open when the forms insert occurs, the #Error behavior occurs. If the connection is closed everything is good. Inserts and updates still happen. Therefore, close the connection as soon as possible. I did it like this (the Cnn.RecordsetOpen function is custom and has a connection.open statement in it before the ADODB recordset open statement).

'FORM LOAD EVENT
Sub load
On Error Goto Standard_Err
    Dim TSQL As String
    Set Me.Recordset = Cnn.RecordsetOpen(SQL)
Standard_Exit:
    Cnn.connection.close
    Exit Sub
Standard_Err:
    Msgbox err.description
    Resume Standard_Exit
End sub

这篇关于数据输入表单在先前记录的大多数列中显示#error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆