Results 1 to 8 of 8
  1. #1
    beru777 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    4

    "On Current" event and ActiveX controls

    Hi,

    Using Access 2007 sp2, if I create a form and drop an activex treeview control (MS Common controls 6.0 sp6) on it, then write an event handler for the "On Current" event like this:

    Code:
    Private Sub Form_Current() 
         TreeView4.Nodes.Clear 
     End Sub
    I get a "Runtime error 438 Object doesn't support this property or method" whenever the event is fired.



    However, if I put the exact same code in an "On update" handler, or even a button click event handler, it works fine.

    Is there anything I can do to make things work properly in the "On Current" event ?


    Thanks,
    Béru

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what are you updating? and why does it need to be on the "current" event?? what are you doing? what's the tview displaying??

    there might be a problem between the invoke process of the treeview and the form's events.

  3. #3
    beru777 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    4
    I'm displaying some data about the current record. It's a split form, I need to update the treeview every time the user navigates to another record...

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by beru777 View Post
    I'm displaying some data about the current record. It's a split form, I need to update the treeview every time the user navigates to another record...
    does the actual active x control have an attributes hierarchy associated with it? for instance, the web browser control's hierarchy is basically the same as the DOM in html.

    reason - can you refresh it or something?

  5. #5
    beru777 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    4
    I have tried all sorts of things but the properties specific to the TreeCtrl class simply do not "exist" within "on current" event handlers. So I used a trick: change focus from one control to another and use the GotFocus event of that control to update my treeview. It's ugly but it works.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by beru777 View Post
    I have tried all sorts of things but the properties specific to the TreeCtrl class simply do not "exist" within "on current" event handlers. So I used a trick: change focus from one control to another and use the GotFocus event of that control to update my treeview. It's ugly but it works.
    the current event has absolutely nothing to do with whether or not properties and methods for an object, active x or not, exist.

    but if you've solved it, I'm going to mark this thread as such. If you want to reopen it, please do so.

  7. #7
    beru777 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    4
    Well they should not have anything to do with whether or properties and methods exist... but they do... try it for yourself: drop an activex treeview in a form, and just try and clear the nodes in the Form_current event...

    anyway, "solved" is fine by me, although I would like to have an explanation of this very strange behaviour !

    Thanks,
    Beru

  8. #8
    CSchnorr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    1

    same error in my form

    This seems to be a "Thread" or ActiveX-Security Thing. The invocation of the Code has no access to the ActiveX Memory. As I faced as well problems with the Setfocus, for I activated Records from within the Table view I search for an alternative solution.

    It can be overcome by creating a "thread safe" callout.

    I have a separate module with

    Function SendApplicationMessage(aform As String, amessage As String, Optional avalue)
    Dim adlg As Form
    On Error GoTo notopen
    Set adlg = Forms(aform)
    adlg.Message amessage, avalue
    postnotopen:
    On Error GoTo 0
    Set adlg = Nothing
    Exit Function
    notopen:
    Resume postnotopen
    End Function

    This allows me to send "Custom events" between Access Forms, that are equipment with a public Interface procedure:

    public sub Message(acmd as string, apar as variant)
    select acmd
    case "DOITTHREADSAFE"
    ' do whatever I want with the tree object
    end select
    end sub

    Hope this is suitable to someone ;-)

    Carsten

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

Similar Threads

  1. Replies: 7
    Last Post: 01-19-2011, 10:39 AM
  2. Replies: 12
    Last Post: 06-14-2010, 08:39 PM
  3. Bound controls "mis"behaving
    By DanW in forum Forms
    Replies: 3
    Last Post: 11-16-2009, 11:35 AM
  4. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

Tags for this Thread

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