Results 1 to 2 of 2
  1. #1
    DepricatedZero's Avatar
    DepricatedZero is offline Cthulhu Fhtagn!
    Windows 8 Access 2007
    Join Date
    Apr 2013
    Location
    Cincinnati
    Posts
    65

    Assign a function to an event manually


    I've been searching around for a way to do this. This link here http://www.office-archive.com/3-ms-a...e42498c09b.htm SEEMS to detail what I need and offer the method even, but it's not working. So I'll explain in detail what I'm trying to do and provide my code examples.

    So I'm trying to 'call out' fields that are being validated on my form. These change based on what is passed via OpenArgs. Fields are called out by setting their BorderColor to red. I want to assign a new "AfterUpdate" event to these fields, to cause them to validate and go blue if they validate

    The code I'm trying looks something like this:

    Code:
    Private Sub SetForValidation(box As Control)
        If box.Enabled Then
            box.BorderColor = RGB(255, 0, 0)
            box.AfterUpdate = "=AfterUpdateGoBlue()"
        End If
    End Sub
    
    
    Private Sub AfterUpdateGoBlue()
        Debug.Print "afterupdategoblue activated"
    End Sub
    I've tried placing AfterUpdateGoBlue into a separate module as suggested in the link, but that hasn't helped either. Right now I'm just trying to get it to assign the function.

    I'm using Access 2007. Can anyone see what I'm doing wrong with this?

    Thanks!

  2. #2
    DepricatedZero's Avatar
    DepricatedZero is offline Cthulhu Fhtagn!
    Windows 8 Access 2007
    Join Date
    Apr 2013
    Location
    Cincinnati
    Posts
    65
    SOLUTION:

    I figured this out after posting this and tooling around with it a bit more:

    Here's the code:

    Code:
    Private Sub SetForValidation(box As Control)
        If box.Enabled Then
            box.BorderColor = RGB(255, 0, 0)
            box.AfterUpdate = "=AfterUpdateGoBlue(" & box.name & ")"
        End If
    End Sub
    
    Private Function AfterUpdateGoBlue(box As Control)
        box.BorderColor = RGB(31, 73, 125)
    End Function
    The magic change seemed to be in changing "Private Sub AfterUpdateGoBlue" to "Private Function AfterUpdateGoBlue"

    Seems strange to me that it would want it to be a function even though I'm not returning anything, but maybe that's what it needs in order to return itself.

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

Similar Threads

  1. After Update Event with power function
    By Fish218 in forum Forms
    Replies: 5
    Last Post: 01-15-2013, 01:29 PM
  2. Replies: 1
    Last Post: 12-08-2012, 01:34 PM
  3. Assign F5 function to a button
    By eduardo in forum Forms
    Replies: 4
    Last Post: 06-24-2012, 08:21 AM
  4. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  5. Replies: 2
    Last Post: 07-19-2011, 04:28 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