Solved

Check command button status on another form

Posted on 2013-12-23
5
412 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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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 47

Expert Comment

by:Dale Fye (Access MVP)
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 47

Expert Comment

by:Dale Fye (Access MVP)
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

749 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