?
Solved

Check command button status on another form

Posted on 2013-12-23
5
Medium Priority
?
425 Views
Last Modified: 2013-12-23
I have a switchboard that opens a form.  The switchboard has three command buttons: cmdBrowse, cmdEdit, cmdNew.   They all open the same form.  I want to set up the form according to which button was selected.  How can I know what button was selected?

I've been trying code like:
If Forms![Switchboard]![cmdBrowse] = True

Thanks,
Brooks
0
Comment
Question by:gbnorton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 39736758
You may open the form with parameter to add or edit or readonly
DoCmd.OpenForm "a", acNormal, , , acFormAdd
DoCmd.OpenForm "a", acNormal, , , acFormEdit
DoCmd.OpenForm "a", acNormal, , , aacFormReadOnly
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 39736875
Another way to do it is from one of the Form2 events, probably the Open, Load, or Timer event, with code like:

Select Case Form_Form1.activecontrol.name
    Case "cmdBrowse"
        'do something here
    Case "cmdEdit"
        'do something here
    Case "cmdNew"
        'do something here
End Select
 
You could also use:

Select Case Forms("Form1").activecontrol.name
0
 

Author Closing Comment

by:gbnorton
ID: 39736905
Exactly!  Thanks Fyed
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39736922
Glad to help.  

This should normally work, but if the code behind the click event of one of those buttons on your first form sets the focus to another control then you may not get the results you are expecting.
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39736925
Another way would be to use the OpenArgs argument of the OpenForm method and pass the name of the commandbutton, something like:

docmd.OpenForm "formname",,,,,acDialog, "cmdBrowse"
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question