Access 2010 Recordset Ms在某些计算机上不会绑定到组合框(Ms Access 2010 Recordset will not bind to combobox on some m

编程入门 行业动态 更新时间:2024-10-26 14:36:56
Access 2010 Recordset Ms在某些计算机上不会绑定到组合框(Ms Access 2010 Recordset will not bind to combobox on some machines)

我有一个Access 2010数据库,它是一个访问2007数据库。 它使用网络服务器上的第二个数据库。

我正在开发Windows 7 32位。

以下是我继承的代码......

我遇到的问题是,虽然数据集绑定到组合框(Combo96)对于我来说在“开发模式”和“运行模式”中都很好,但它也适用于另一台Windows 7 32位机器和另一台Windows 7 64位机器。 它拒绝在一台32位机器上工作。

我猜测它的参考问题? 我所知道的目标(失败)机器就是Windows 7,它具有访问2010运行时,它可能具有访问权限2007或访问2007运行时,我真的没有办法找到答案。

我在底部添加了代码,该代码获取数据集并将其复制到组合框。 这适用于所有机器,但需要相当长的时间。

任何想法为什么数据集不会在某些机器上绑定到combo96?

On Error GoTo err_hand Dim SearchStr As String Dim oRec As ADODB.Recordset Combo96.RowSource = "" txtSearch.SetFocus SearchStr = Trim(txtSearch.text) Set oRec = New ADODB.Recordset ' [Client Number], strQuery = "SELECT replace(replace([Company],"","","""" ),"":"","""") as [Companys] FROM tblClient where company <> '' ORDER BY [Company] " oRec.Open strQuery, Load_ribbon.get_Connection, adOpenKeyset, adLockOptimistic Me.Combo96.RowSourceType = "Table/Query" Set Me.Combo96.Recordset = oRec oRec.Close err_endit: Set oRec = noting Exit Sub err_hand: Call sendReport.SendErrorDetail("CMP-0701-" & Erl, "Can't Read [Clients] Data SRC-" & SearchStr & "-" & Err.Description & "-" & Err.Number) ' Here comes some Cheese!!!! On Error GoTo Skippy ' Bounding probably failed Try manual If Not (oRec Is Nothing) Then If oRec.RecordCount > 0 Then If oRec.RecordCount > 1000 Then MsgBox ("Too amany records found please be more specific") Else Me.Combo96.RowSourceType = "Value List" oRec.MoveFirst Do While Not RS.EOF Me.Combo96.AddItem RS![Company] oRec.MoveNext Loop End If End If End If Resume err_endit Skippy: MsgBox ("Run-Time Error CMP-0702-" & Erl & " Can't Read [Clients] Data") Call sendReport.SendErrorDetail("CMP-0702-" & Erl, "Can't Read [Clients] Data SRC-" & SearchStr & "-" & Err.Description & "-" & Err.Number) Resume err_endit

I have an access 2010 database that was an access 2007 database. It uses a 2nd database on a network server.

I am developing in windows 7 32bit.

Below is the code I have inherited...

The problem I am having is that while the dataset binds to the combobox (Combo96) just fine for me in 'development mode' and in 'run mode' and it also works ok another windows 7 32bit machine and yet another windows 7 64bit machine. It refuses to work on one windows 32bit machine.

I'm guessing its a problem with references? All I know about the target (failing) machine is that is windows 7, it has the access 2010 runtime, it may have access 2007 or access 2007 runtime, I don't really have a way to find out.

I added the code at the bottom that takes the dataset and copies it to the combobox. This works just fine on all machines but takes considerably longer.

Any Ideas why the dataset wont bind to combo96 on some machines?

On Error GoTo err_hand Dim SearchStr As String Dim oRec As ADODB.Recordset Combo96.RowSource = "" txtSearch.SetFocus SearchStr = Trim(txtSearch.text) Set oRec = New ADODB.Recordset ' [Client Number], strQuery = "SELECT replace(replace([Company],"","","""" ),"":"","""") as [Companys] FROM tblClient where company <> '' ORDER BY [Company] " oRec.Open strQuery, Load_ribbon.get_Connection, adOpenKeyset, adLockOptimistic Me.Combo96.RowSourceType = "Table/Query" Set Me.Combo96.Recordset = oRec oRec.Close err_endit: Set oRec = noting Exit Sub err_hand: Call sendReport.SendErrorDetail("CMP-0701-" & Erl, "Can't Read [Clients] Data SRC-" & SearchStr & "-" & Err.Description & "-" & Err.Number) ' Here comes some Cheese!!!! On Error GoTo Skippy ' Bounding probably failed Try manual If Not (oRec Is Nothing) Then If oRec.RecordCount > 0 Then If oRec.RecordCount > 1000 Then MsgBox ("Too amany records found please be more specific") Else Me.Combo96.RowSourceType = "Value List" oRec.MoveFirst Do While Not RS.EOF Me.Combo96.AddItem RS![Company] oRec.MoveNext Loop End If End If End If Resume err_endit Skippy: MsgBox ("Run-Time Error CMP-0702-" & Erl & " Can't Read [Clients] Data") Call sendReport.SendErrorDetail("CMP-0702-" & Erl, "Can't Read [Clients] Data SRC-" & SearchStr & "-" & Err.Description & "-" & Err.Number) Resume err_endit

最满意答案

考虑使用Combo96.RowSource中的SQL查询而不是Combo96.Recordset属性。 如果tblClient在连接后在本地可用,则在VBA中将组合框的rowsource设置为

SELECT replace(replace([Company],"","","""" ),"":"","""") as [Companys] FROM tblClient where company <> '' ORDER BY [Company] 。

显然,有一些警告说明如何打开ADODB Recordset将其分配到组合框/列表框。 看到这个论坛帖子: 使用记录集填充组合框

It turned out this is a problem with the Access runtime. Because both 2007 and 2010 were installed it is necessary to choose which one Access should run under.

更多推荐

本文发布于:2023-07-04 17:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1027062.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   机上   绑定   在某些   Recordset

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!