Hi Everyone,
I wonder if anyone out there has deployed a solution successfully like mine?

I have created a vb.net 2005 winform solution that can be installed on a desktop.
It uses an access 2003 database to hold data. The setup.msi was created using the vs.net
deployment menus. The solution uses access reports to show lots of different reports, basically because the reporting package in VB.net, in my opinion, isnt anywhere near as good as reports in access. Access 2003 runtime is used and installed if the client PC hasnt got Access 2003. It isnt installed if the client has Access 2003.

Everything deploys OK as long as the client pc hasnt got any other version of access.
If the client has Access 2000 however, although the connections work allowing data to be viewed, added, updated and deleted, the reports wont work giving error 429, cannot create Activex object. I presume the deployed solution is getting confused about which MSACCESS.exe to use as there is more than 1 present. Invariably its going for the wrong version!

Has anyone figured out a way of testing to see if there are more than 1 msaccess.exe present and if so to select the correct one to use? Any advice would be great as I am a bit stuck currently.

thanks
Waldek

I do something similar all the time for AutoCAD, they come out with a new version each year so I have to be specific in which version I want to talk to and there may be several versions in use on the one computer.

Are you connecting to Access via a COM connection (e.g. object.GetActiveObject(<classString>)) or is it strictly managed?

If its COM then you can use the appropriate Class string to dictate which version of Access you want to connect to.

Can I see some code where you connect to Access and get a reference to it?

Hi Sling Blade,
thanks for your response. First bit of code calls report. Second calls routine I copied from internet search.

Private Sub btnChildListingAZAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChildListingAZAll.Click
        'open access report 
        Dim AccessPath As String
        Dim dbPath As String
        Try
            dbPath = strFullDataPath
            AccessPath = GetOfficeAppPath("Access.Application", "msaccess.exe")
            If Dir(dbPath) = "" Then
                MessageBox.Show("Database at " & dbPath & " could not be found", "Database Location", MessageBoxButtons.OK)
                Exit Sub
            End If
            If Dir(AccessPath) = "" Then
                MsgBox("Couldn't find Microsoft Access.")
                Exit Sub
            Else
                Shell(PathName:=AccessPath & " " & Chr(34) & dbPath & Chr(34))
                System.Threading.Thread.Sleep(1000) 'wait 1 seconds
                accApp = GetObject(dbPath)
            End If
            strReport = "rptChildListingAZAll"
            With accApp
                .RunCommand(Command:=Access.AcCommand.acCmdAppMaximize)
                .DoCmd.OpenReport(strReport, Access.AcView.acViewPreview, , , Access.AcWindowMode.acWindowNormal)
                If .Visible = False Then
                    .Visible = True
                End If
            End With
            accApp = Nothing
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Access Error", MessageBoxButtons.OK)
            MsgBox("Error opening Access Report.  Cannot Proceed.", MsgBoxStyle.OkOnly, "Access Error")
            Exit Sub
        End Try


    End Sub

 Public Function GetOfficeAppPath(ByVal sProgId As String, ByVal sEXE As String) As String
        'Returns path of the Office application. e.g.
        'GetOfficeAppPath("Access.Application", "msaccess.exe") returns
        'full path to Microsoft Access. Approach based on Q240794.
        'Returns empty string if path not found in registry.

        ' Enable an error handler for this procedure:
        On Error GoTo ErrorHandler

        Dim oReg As Microsoft.Win32.RegistryKey = _
            Microsoft.Win32.Registry.LocalMachine
        Dim oKey As Microsoft.Win32.RegistryKey
        Dim sCLSID As String
        Dim sPath As String
        Dim iPos As Integer

        ' First, get the clsid from the progid from the registry key
        ' HKEY_LOCAL_MACHINE\Software\Classes\<PROGID>\CLSID:
        oKey = oReg.OpenSubKey("Software\Classes\" & sProgId & "\CLSID")

        sCLSID = oKey.GetValue("")
        oKey.Close()

        ' Now that we have the CLSID, locate the server path at
        ' HKEY_LOCAL_MACHINE\Software\Classes\CLSID\ 
        ' {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}\LocalServer32:
        oKey = oReg.OpenSubKey("Software\Classes\CLSID\" & sCLSID & "\LocalServer32")
        sPath = oKey.GetValue("")
        oKey.Close()

        ' Remove any characters beyond the exe name:
        iPos = InStr(1, sPath, sEXE, CompareMethod.Text)
        sPath = Microsoft.VisualBasic.Left(sPath, iPos + Len(sEXE) - 1)
        Return (Trim(sPath))
ErrorHandler:
        Return ""
    End Function

Edited 5 Years Ago by __avd: Added [code] tags.

This article has been dead for over six months. Start a new discussion instead.