Determine the calling procedure

mredmond

Registered User.
Local time
Today, 16:36
Joined
Oct 1, 2003
Messages
32
Is there a way to know, from within module C, whether it was called from module A or module B? In the VBA editor, there is a button for viewing the Call Stack. Can this stack be read from within VBA code?

Thanks.
 
Hi Mike

You could pass a parameter from the calling procedure

ProcA()

Call ProcC(1)


End


ProcB()

Call ProcC(2)


End


ProcC(Callerid as integer)

Select case Callerid

Case 1
Msgbox " ProcA called"

Case 2
Msgbox "ProcB called"
End select

End

HTH

Norman
 
Thanks for your response. This does work for procedure to procedure, even module to module. But, I should have been more specific. I was looking for a way to know which procedure had issued the OpenForm call. Actually, I solved my problem using the OpenArgs parameter of the OpenForm call. I simply did like you said, passed a 1 or 2 in the OpenArgs paramenter and then did the following:

vCallingProc = Me.OpenArgs

Then I test as you said, for the value of vCallingProc and executed code as needed.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom