Results 1 to 9 of 9
  1. #1
    RA99 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Location
    Regina, Saskatchewan, Canada
    Posts
    23

    PrintOut Macro Works, PrintOut VBA Doesn't

    Here's an odd one. I have a simple Printout macro on a command button on a subform that looks like:



    Code:
    OpenReport  MemberCardL,Report,,,Normal
    PrintOut All,,,High,1,Yes
    Close Report,MemberCardL,Yes
    This works fine as such. However, I need to combine the printout action with an update query on the same command button. But when I convert the macro to VBA thusly:

    Code:
    Private Sub Command30_Click()
    DoCmd.OpenReport "MemberCardL", acViewPreview
    DoCmd.PrintOut , , , , 1
    DoCmd.Close acReport, "MemberCardL", acSaveNo
    End Sub
    and run it I get an error message, "The expression On Click you entered as the event property setting produced the following error: A problem occurred while Radius Admin. System was communicating with the OLE server or ActiveX Control."

    The help for that error says
    "This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired."

    I can't find any property that would trip up VBA as compared to the macro, and there is lots more command button VBA code on the same subform that works fine. Has anyone seen this situation before?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Comment out all of your code for the click event then, in the Command Control's Click Event property (within the Property Sheet while in Design View), clear the text.

    Then, create a new click event and add your VBA.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    An UPDATE query object can be run from a macro.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Try this: Also, make sure your OLE Server is registered in your References.


    DoCmd.OpenReport "MemberCardL", acViewPreview
    DoCmd.PrintOut acPages, 1, 1
    DoCmd.Close acReport, "MemberCardL"
    HTH

  5. #5
    RA99 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Location
    Regina, Saskatchewan, Canada
    Posts
    23
    Thanks for the suggestions. I tried all offered advice to fix the VBA code, but cold not make the error go away. Consistent with June 7th's suggestion I tried to run the update query in a macro by dropping the query code into a function and using a RunCode. My function code is

    Code:
    Function Clear_MemberCard_Print()
    DoCmd.SetWarnings False
    Dim SQL As String
    SQL = "UPDATE MembersT SET MemberSpecial = Null "
    DoCmd.RunSQL SQL
    DoCmd.SetWarnings True
    End Function
    The PrintOut part of the process works (i.e. the report gets printed), but the macro fails on the RunCode step, with the message "A problem occurred while Radius Admin. System was communicating with the OLE server of ActiveX control" The help message advises to close and reopen the OLE server, which I presume means to remove it and re-add to my references table, but that did not work. My references at present are:

    VBA
    MS Access 12.0 Object Library
    MS Access database engine object library
    OLE Automation
    MS ActiveX Data Objects 2.5 Library

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is split db? What is the backend?

    My suggestion was to try running the query within the macro, not call a VBA function. The OpenQuery method can execute a saved SQL action object.

    The RunSQL action allows SQL statements within macro http://office.microsoft.com/en-us/ac...001226285.aspx.

    Don't think I've ever used ActiveX controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    RA99 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Location
    Regina, Saskatchewan, Canada
    Posts
    23
    Quote Originally Posted by June7 View Post
    This is split db? What is the backend?
    It's not split, are you reading this from my references list, i.e. do I have unneeded items there?

    At any rate, the update procedure runs correctly from RunSQL, so thanks for that! I'm concerned about why I've got this one very difficult command button, whether it indicates I've got something corrupted somewhere, and whether that will come back to bite me some time, but for now, the command process does the job.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Shouldn't hurt to have unneeded libraries checked, as long as Access has the referenced dll available. I cannot understand why this is happening without analyzing db. If corruption is at the root, only way to be sure is to rebuild. Start with button and keep going up the chain until the behavior no longer exhibits. If even then it persists, is something very weird indeed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    RA99 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Location
    Regina, Saskatchewan, Canada
    Posts
    23
    An update on this issue. They say the simplest solution ...?? The corruption appears to be in the form. Copy form, delete original, rename the copied form and presto, no more crazy-making errors. Sigh.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-21-2013, 10:06 PM
  2. Replies: 1
    Last Post: 01-12-2012, 02:54 AM
  3. PrintOut Macro Action
    By EHittner in forum Access
    Replies: 1
    Last Post: 09-22-2011, 01:27 AM
  4. PrintOut action
    By svcghost in forum Programming
    Replies: 11
    Last Post: 10-05-2010, 05:13 PM
  5. Replies: 1
    Last Post: 05-27-2006, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums