One way to do this is to use the OpenArgs parameter of the form. You can
send information from one form to another with this parameter. So assuming
you have a button named Button1 (and I hope it's not) you can do this in its
OnClick event:
stDocName = "customer2"
DoCmd.OpenForm stDocName, , , , , , "Button1"
In the Customer2 form, you would read the OpenArgs string in the OnLoad
event and use it somehow. For instance, you could set this value to the
caption of a label to display which button was pushed. Something like this:
Private Sub Form_Load()
Me.Label10.Caption = Nz(OpenArgs, "")
End Sub
This will cause the value "Button1" to appear in the label when the second
form is opened.
Note: I usually use the Nz function in case the form is opened without that
argument. Under some circumstances (like if you were assigning the value to
a variable) a Null value in the OpenArgs will cause an Error.
--
--Roger Carlson
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L