Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / November 2004

Tip: Looking for answers? Try searching our database.

Find what button was clicked

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcus - 24 Nov 2004 09:57 GMT
On my form I have 5 choices (each opens a form). The form's display will
change according to what was clicked from the previous form. (eg hide, or
display controls)

What is the code to trap the last button  or control clicked.

I have done this years ago back in Access2 but cannot remeber how.
Thanks
Ken Snell [MVP] - 24 Nov 2004 14:00 GMT
Assuming that the button that was clicked still has the focus, use
   Screen.ActiveControl.Name
to get the name of the button.

Signature

       Ken Snell
<MS ACCESS MVP>

> On my form I have 5 choices (each opens a form). The form's display will
> change according to what was clicked from the previous form. (eg hide, or
[quoted text clipped - 4 lines]
> I have done this years ago back in Access2 but cannot remeber how.
> Thanks
Roger Carlson - 24 Nov 2004 14:14 GMT
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.

Signature

--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

> On my form I have 5 choices (each opens a form). The form's display will
> change according to what was clicked from the previous form. (eg hide, or
[quoted text clipped - 4 lines]
> I have done this years ago back in Access2 but cannot remeber how.
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.