I have been banging my head against the wall on this one.
I have a VBA function that get a users username and department. That function works fine. I have some code that needs to run when the DB is first opened so I used an autoexec macro that calls a VBA function:
My syntax might be off but trust me that code works. And I have Global user and Global dept stated at the top of this module.
I have a form that opens and needs the user and dept variables to populate some fields. The fields get populated correctly. Using default value = user on form open.
But I put a button on the form that pops up a msgbox with the username. This msgbox is EMPTY. Same with dept.
Why are the variables not sticking around? I need these variables constantly accessible throughout the session and between multiple forms.
I have a VBA function that get a users username and department. That function works fine. I have some code that needs to run when the DB is first opened so I used an autoexec macro that calls a VBA function:
Code:
public function db_open()
user = getuser()
dept = getdept()
DoCMD.openform "introform"
My syntax might be off but trust me that code works. And I have Global user and Global dept stated at the top of this module.
I have a form that opens and needs the user and dept variables to populate some fields. The fields get populated correctly. Using default value = user on form open.
But I put a button on the form that pops up a msgbox with the username. This msgbox is EMPTY. Same with dept.
Why are the variables not sticking around? I need these variables constantly accessible throughout the session and between multiple forms.