You'll still need the onclose event of your form, just insted of the
below code in it, you'll just make a function call insted. Place the
below code in a function, in a module, and in the onclose event, just
call the function from your module just as you would call any other
function.
Also, I understand the variable defining, but it has always been my
own personal opinion that if you never use a variable, you can get rid
of it entirely (stLinkCriteria) and if you're only using it once, you
don't really need it either (stdocname). Defining two unnecessary
variables may not seem like a lot, but spread out over many forms used
repeatedly, it is a waste of memory. Getting rid of unnecessary
variables is an easy way to make your program run slightly faster and
use less memory. Again, just my personal opinion - take it however
you want.
lu*************@aol.com (Lumpierbritches) wrote in message news:<20***************************@mb-m11.aol.com>...
I have code that is currently placed in the OnClose Event, and it's duplicated
in multiple forms, I would like to convert it to a module and call that module
instead of copy and pasting the code. Here is the code:
If IsNull(Forms!frm1!FormHolder) Then
DoCmd.OpenForm "Switchboard"
Else
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = Forms!frm1!FormHolder
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Thank you in advance for your assistance. Frm1 is open all the time in a Hidden
mode.
Michael