'Macro Design - Calling Function

I have a question about the Macro Design in a table for a "After Update" function. In one database that one of my past employees built the "SetField" value as a function call. One of the functions it calls is called GetUserNAme() it is buried in another bas_AuditLog macro, but in a DB that I am building, it doesn't work, even though I thought I had all of the information copied and correct. I have attached an image here that might show my issue. Notice the red exclamation mark.

Image of Macro Builder with error

Perhaps one of you smart people can help me look at an area that in my DB that may have the missing link.

Thanks.



Solution 1:[1]

Ok, so in the other (working) applcaiton, there is a going to be a public function called GetUserName(), and it is a VBA function.

So, in that working applcation, you can hit ctrl-g (get to debug window), and then type in GetUserName and then hit shift f2. Your code editor should now jump to that VBA function. You need to copy that code to your new applcation (place it in a plane jane standard code module (not a forms module, and not a class module). and it might very well also use a api call.

So, when you copy over that code. Test and make sure the VBA code works. In most cases in the access debug window, you can type in this:

? GetUserName()

And it should spit out the current windows user name. (or whatever the code supposed to do). So, get the VBA function working, and once you do, then your data macro should now also work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Albert D. Kallal