locked
Access Runtime Functionality RRS feed

  • Question

  • I have a overview database pulling in data from 3 other SQL Databases.

    At the front end I use a VB.Net GUI app, to keep the data "Live" I re-query every 5 minutes and also on opening of the Vb.Net app.

    When running on my own Laptop with full Access I do not have an issue. When running on other PC's with the run time I get the following:

    .....there would have been an image of the Unhandled exception here if my account was already verified!

    Anyway it states that it "Cannot create ans Active X component and the exception text does sate xxxxx.xxxxx.reQuery_Access()

    I will include an image once I am fully verified.

    I am assuming it is due to the limited functionality of Access Runtime, is my assumption correct, if so can anyone advise me of a work around?

    Regards

    Simon

    Wednesday, September 12, 2018 9:49 AM

All replies

  • Hi Simon,

    If you're using something like CreateObject("Access.Application") then yes, it won't work in a runtime environment because runtime does not have this capability.

    Just my 2 cents...

    Wednesday, September 12, 2018 2:49 PM
  • Hello, thank you for replying.

    I am not using CreateObject, I am using GetObject as in....

        Sub reQuery_Access()
    
            'Opens the database And runs a Re-Query function to update the data
            Dim accApp As Object
    
            accApp = GetObject(Constants.myDataScource)
            accApp.Visible = False
            accApp.docmd.OpenQuery("Common Data Set")
            accApp.docmd.OpenQuery("Sales Order Notes")
            accApp.docmd.OpenQuery("Sales Order Number")
            accApp.docmd.OpenQuery("Works Order Number")
            accApp.docmd.OpenQuery("Contract Number")
            accApp.docmd.OpenQuery("Contract Worked On Status")
            accApp.docmd.OpenQuery("Contract in Build")
            accApp.docmd.OpenQuery("Contract in Paint")
            accApp.docmd.OpenQuery("Contract in Test")
            accApp.docmd.OpenQuery("Contract in BTU")
            accApp.docmd.OpenQuery("Personnel in Build")
            accApp.docmd.OpenQuery("Personnel in Paint")
            accApp.docmd.OpenQuery("Personnel in Test")
            accApp.docmd.OpenQuery("Personnel in BTU")
            accApp.CloseCurrentDatabase()
            accApp.Quit
    
        End Sub

    Friday, September 14, 2018 12:59 PM
  • Hi,

    I could be wrong but GetObject could also be "creating" an object for Access to use. I would recommend adding an error handler to indicate exactly where the error is coming from.

    Just my 2 cents...

    Friday, September 14, 2018 3:01 PM
  • What is the value of Constants.myDataScource?

    You need to Set objects, so

    accApp = GetObject(Constants.myDataScource)

    needs to be

    Set accApp = GetObject(Constants.myDataScource)

    Like theDBguy stated, I'd add proper error handling and see what gets returned and go from there

    Sub reQuery_Access()
              'Opens the database And runs a Re-Query function to update the data
              Dim accApp                As DAO.Database 'Object
    
    10        On Error GoTo Error_Handler
    
    20        Set accApp = GetObject(Constants.myDataScource)
    30        accApp.visible = False
    40        accApp.DoCmd.OpenQuery ("Common Data Set")
    50        accApp.DoCmd.OpenQuery ("Sales Order Notes")
    60        accApp.DoCmd.OpenQuery ("Sales Order Number")
    70        accApp.DoCmd.OpenQuery ("Works Order Number")
    80        accApp.DoCmd.OpenQuery ("Contract Number")
    90        accApp.DoCmd.OpenQuery ("Contract Worked On Status")
    100       accApp.DoCmd.OpenQuery ("Contract in Build")
    110       accApp.DoCmd.OpenQuery ("Contract in Paint")
    120       accApp.DoCmd.OpenQuery ("Contract in Test")
    130       accApp.DoCmd.OpenQuery ("Contract in BTU")
    140       accApp.DoCmd.OpenQuery ("Personnel in Build")
    150       accApp.DoCmd.OpenQuery ("Personnel in Paint")
    160       accApp.DoCmd.OpenQuery ("Personnel in Test")
    170       accApp.DoCmd.OpenQuery ("Personnel in BTU")
    180       accApp.Close
          '    accApp.CloseCurrentDatabase()
    190       accApp.Quit
    
    Error_Handler_Exit:
    200       On Error Resume Next
    210       If Not accApp Is Nothing Then Set accApp = Nothing
    220       Exit Sub
    
    Error_Handler:
    230       MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
                     "Error Number: " & Err.Number & vbCrLf & _
                     "Error Source: reQuery_Access" & vbCrLf & _
                     "Error Description: " & Err.Description & _
                     Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
                     , vbOKOnly + vbCritical, "An Error has Occured!"
    240       Resume Error_Handler_Exit
    End Sub


    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Friday, September 14, 2018 11:34 PM