Search code examples
vbams-access-2007ms-access-2010adodao

Ms Access 2010 Recordset will not bind to combobox on some machines


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

Solution

  • 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.