Custom shortcutmenu for commandbutton to open form with arguments

How does one create a custom shortcutmenu to set to a CommandButton that will 
open up a form passing in arguments from the current form, all in Access 2007 
and VBA?
0
Utf
1/5/2010 3:46:01 AM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies
1271 Views

Similar Articles

[PageSpeed] 9

Attached is some code that I use for a custom shortcut menu that I use on
most of my forms.  I call the subroutine when my Splash screen loads, and
then use the click event of a control on my form (usually a label in the
upper left corner of the form) to display the shorcut menu, using:

CommandBars("MyFormMenu").ShowPopup

What you will need to do is change the references to fnCloseForm to a new
function that you write.
You can then declare a form variable (Dim frm as Form) and set it to the
screen.activeform.  Once you have done that, you can open the new form and
transfer values from the frm.text1 or other controls to controls on the newly
opened form.

HTH
Dale

Public Sub MenuForm()

    Dim cbr As Object
    Dim cbrButton As Object

    If CmdBarExists("MyFormMenu") Then Exit Sub
    On Error GoTo FormMenuError

    DoCmd.Hourglass True

    Set cbr = CommandBars.Add("MyFormMenu", BarPopup, , True)

    With cbr

        Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
        With cbrButton
            .Caption = "&Close"
            .Tag = "Close"
            .OnAction = "=fnCloseForm()"
        End With

        Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
        With cbrButton
            .Caption = "&Quit"
            .Tag = "Quit"
            .OnAction = "=fnQuit()"
        End With

    End With

    DoCmd.Hourglass False
    Exit Sub
FormMenuError:
    MsgBox "ReportMenu error" & vbCrLf
End Sub

Public Function fnCloseForm()

    Dim frm As Form
    
    Set frm = Screen.ActiveForm
    
    On Error Resume Next
    frm.AllowClose = True
    DoCmd.Close acForm, frm.Name
    
End Function

Public Function CmdBarExists(BarName As String) As Boolean

    Dim intControls
    
    On Error Resume Next
    intControls = CommandBars(BarName).Controls.Count
    If Err.Number = 0 Then
        CmdBarExists = True
    Else
        CmdBarExists = False
    End If
    
End Function


xcskiier wrote:
>How does one create a custom shortcutmenu to set to a CommandButton that will 
>open up a form passing in arguments from the current form, all in Access 2007 
>and VBA?

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201001/1

0
Dale_Fye
1/5/2010 4:24:11 PM
Reply:

Similar Artilces:

how to active the ribbon Tab automatically when the form opens[Access 2007]
Dear I built a ribbon tab for a form. It works fine and when the form opening, the ribbon will be loaded fine. But it would be focus (or active) automatically. It still focus in the tab where I set now. Please help.!!urgent.!! Another question: is the callbacks for the ribbon always in Modules? I remember in Access 2003, the callbacks function could be in the form class modules. If all the callbacks should be in the Modules, does it mean we need distinguish which form or report is active now? Thank you very much. Jason Jiang Hi Ribbon is the new command bar system in office 2007...

Excel Worksheet menu bars customizing for limiting users to optio.
Customizing Excel worksheet menu bar for limiting users to the options provided in that menu Hi Jim Look also at the links to MS pages on the bottom of this page http://www.rondebruin.com/menuid.htm -- Regards Ron de Bruin http://www.rondebruin.nl "jim" <jim@discussions.microsoft.com> wrote in message news:F8009001-5F5A-4415-9527-34C71D8DF1DB@microsoft.com... > Customizing Excel worksheet menu bar for limiting users to the options > provided in that menu ...

Excel VBA
I have created a custom menu bar..a section of the code below...but d not know how to create a 2nd level to look like the example below. Period > Month > Current Year (action) Any suggestions. Thanks. ' Add a new menu Set NewMenu = NewMenuBar.Controls.Add _ (Type:=msoControlPopup) NewMenu.Caption = "&Period" ' Add a new menu item Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton) With NewItem .Caption = "&By Month" .OnAction = "Main" End Wit -- Message posted from http://www.ExcelForum.com You should find your answer here (...

Linked Forms
Hello, I am doing a project that requires two forms.. The first form contains the data for a business the second form contains data for the business owner... How do I link the two forms together...? Many thanks. Bob Send a common key piece of data from the first form (say the company name) to the second form page and include it in the second form as a hidden form field (then if using a database to store the results link with a relationship the 2 results tables by the common field) For form passing information see http://irt.org/articles/js063/index.htm -- ____...

Unbound Form for Criteria
Hi everyone, How can I make an unbound form pull criteria for: Month vs. Previous month Current Qtr vs. Previous Qtr Current Qtr vs. Previous Year’s Qtr I’ve been around the world and back again on this. Is it a matter of creating expressions for these in a form or should this be a part of the design of my query. My end result is to have a report showing one period vs. the other period and the variance. Please point me in the right direction…please! Thank you, Kay It will take more than an unbound form for the criteria to get your data. You will have to add a cal...

"a document with the name" error on opening file
I'm getting an error message that says "A documents with the name " & filename & " is already open" (where filename is the actual name of the file) when I try to open certain files in Excel 97, when I don't really have a copy of the file in question opens. This error comes up pretty consistantly on one file that lives on a server, but I also get it when I try to open some local files. Anyone have any idea what would cause this & how to fix it? Thanks in advance. Best Jim Hi Jim have a look at: http://www.contextures.com/xlfaqApp.html#AlreadyOpen ...

cannot open entourage
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: pop The message I get is&quot;Cannot open this database with this version of Entourage&quot;. I have already tried rebuilding the database, doesn't work. Is there anything else you could sugeest? On 2010-06-03 07:27:04 -0400, MacIan@officeformac.com said: > The message I get is"Cannot open this database with this version of > Entourage". I have already tried rebuilding the database, doesn't work. > Is there anything else you could sugeest? Update Entourage...

File in 2007 form
I was trying the Beta Office 2007 and made the mistake of saving one of you Excel file in the new 2007 form. I really need it back in the 2003 form. Problem: due to a variety of issues, I de-installed the Beta version and went back to 2003 but for got about the one file.. So; are there any utilities that anyone knows of the will convert this file back two 2003 form?? It is a simple Excel file, meaning that there are no clever or fancy formula or macros, just a collection of parts and part numbers gathered over MUCH time surfing various web sites. Any help or advise (beside the obvious....

word attachments on e-mail, docx files, recipient unable to open
I have been sending e-mails as I always have and attaching them in the way I always have, all of a sudden word documents are coming up as docx files and the recipients cannot open them, I have only recently gone onto Vista and microsoft offoce 2007. This has only happened recently with new docs that I have created on the new system. It is frustrating my customers and my hair is now falling out. Please help! That's because Word 2007 saves documents in a new format, .docx, unless told to do otherwise. There are two solutions: 1. Do a "Save As" and save documents in Word 97-...

Open a Publisher document without having Publisher
Is it possible? Can I convert the publisher doc to something else to then be able to open it? Can't even be done with a crowbar. You need Publisher, version of the same or later version as the pub file. -- Don Vancouver, USA "edd1121" <edd1121@discussions.microsoft.com> wrote in message news:F2C98EFB-1A94-4976-A9FA-9293B4942113@microsoft.com... > Is it possible? Can I convert the publisher doc to something else to then > be > able to open it? What about a BMF hammer? ;-) -- JoAnn Paules MVP Microsoft [Publisher] "Don Schmidt" <R...

Creating a form
I have a form with a subform that allows a person to enter all the Sold to Ship To on the top form and the details on the subform.I would like to create a print button on the form that they can click after they finish entering the subform information that will print out a P.O. with all the top and subform info correctly placed on it.Is this very difficult? I am just not sure how it will know to print the current record?Thanks for your help After you add a button to the form to print a report, open the code module and modify the OpenReport method to add a where argument. Help and Intellisense ...

attachment is grey cannot open
cannot open attachment. attachment is grey See www.oehelp.com/OETips.aspx#1 The same applies for WinMail. steve "dravidm" <dravidm@discussions.microsoft.com> wrote in message = news:4290840E-7192-446A-940F-5AEC42A8A55C@microsoft.com... > cannot open attachment. attachment is grey ...

Opening Attachments in Outlook 2000
A recent user of mine complained about opening emails with attachments included while on the road, dialing in over a modem line. He wanted to know if there was any way to just receive the text from the message without having to download the attachments once the email is opened....any suggestions? thanks! He could always use www.mailwasher.net to view mail text only. David "**Jeff" <jlemay@artel.com> wrote in message news:0be301c35c23$964d3980$a401280a@phx.gbl... > A recent user of mine complained about opening emails with > attachments included while on the roa...

how do I stop PERSONAL.XLSB from showing every time XL opens?
This workbook comes up every time I open XL - then I have to create a new workbook. How can I stop this workbook from opening automatically? I am using Office 2007. hi if the personal.xlsb is in the xl start folder, it will open with xl. it should open hidden so try hidding it. the personal.xlsb workbook should contain all of your personal macros and stuff that you want available at all times, hidden in the background. if not then remove the workbook from the xl start folder. regards FSt1 "Kerry S" wrote: > This workbook comes up every time I open XL -...

Access 2003 Security Message On Open
All, I have approximately 15 databases that I am about to migrate to Access 2003 from 2000. I do not want the security message to appear every time one of my users logs on to the database. Registry changes and digital signatures are out of the question. If I put Application.AutomationSecurity = msoAutomationSecurityLow on open of my start up form will this prevent the warning message? Is there something I can put in the windows shortcut to turn this off? I have seen some suggestions were it is mentioned to call a script that calls the database to open in low security mode. Is this nec...

Money 2002 opens very slowly! Started few days ago!!! HELP
Hi to all, I have problem with Money2002. It is full with data from last year and until few days ago everything was ok. In average it would took about 3-5sec for MsMoney to open all the data, but since yesterday I need to wait app 10- 15sec for MsMoney to open. I tried everything but no luck. Anybody have a clue what this could be. Thanks in advance Is 15 seconds really that long to wait? What other programs and data have you installes/saved in the last year. Is your drives getting full? In microsoft.public.money, John wrote: > >I have problem with Money2002. It is full with...

Search directly in a form
I have some members in av form, and I want to be able to in [FirstName] to just type inn the persons name and search an get hold of all the persons data in the form. Is there an easy way to do this? -- Tom R. Thorstensen On Tue, 8 Jan 2008 07:31:04 -0800, Tom R. <tomrth@broadpark.no> wrote: >I have some members in av form, and I want to be able to in [FirstName] to >just type inn the persons name and search an get hold of all the persons data >in the form. Is there an easy way to do this? Yes. On the menu select Records... Filter... Filter by Form. Type search terms in...

ADP in A2007 Runtime: Traditional binding of form to stored procedure taking no parameters no longer works
Forms in ADP can have a stored procedure as the RecordSource. Traditionally we could write: RecordSource="dbo.EmployeesList" (or use the RecordSourceQualifier to specify "dbo"). On A2007 runtime this no longer works: The record source 'EmployeeList' specified on this form or report does not exist. On A2007 (with or without the /runtime command line switch) it does work. The only workaround I have found so far is to put the entire expression in the RecordSource property like this: "exec dbo.EmployeesList". I don't think this is an intentional change b...

Custom Reports in Reports not available??
2 questions... 1. I just figured out how to download the reports available. I just realized that when I go to reports in store operations manager, the custom reports option is not available. Is there a reason for this? How can I fix this? 2. I really need to do a report on customers. I need to know how much money a list of customers has spent between certain dates. I can't seem to get any of my report options to let me do all of those things at once. EX. customers that spent greater than or equal to $50 between 11/1/06 and 12/31/06 and to have it list the total sales for that time fr...

error message while opening the stored proc.
Can anybody view the stored procedure code - installed by eConnect on GPS database (Stored procs created after you install eConnect e.g. taSopHdrIvcInsert) I get error message while opening the stored proc. Error 20585: [SQL-DMO]/*******Encrypted object is not transferable, and script can not be generaqted. ******/ any comments ? ...

[ANN] "Dbl-Click Won't Open..." Issues
This message has been cross-posted to the Macintosh Word, PowerPoint, Excel & Office groups. The problem some of you have been experiencing whereby a file received via email refuses to open when double-clicked has been traced to email and/or web browser software mishandling the file sometime during its life cycle. Apparently certain programs of those types modify a key identifier in MS Office files which the 2008 apps require in order to be activated & open a file when it's double-clicked . Although identity of the software hasn't been identified, MacBU is working with the de...

Custom Fileds
How do you add a drop down list (custom field) to the activities for an account and Is it possible to remove some of the buttons on the side under Sales like quotes, invoices, etc...? Robert, You add custom fields through the deployment manager. Once you have selected the table you want to add a field and choosen Add Schema Field, you will be presented with what kind of field you want to create. Among your choices is a picklist. -Jason "Robert" <Robert@discussions.microsoft.com> wrote in message news:0909FBA0-B107-48D2-AB3C-BA46FF131EF4@microsoft.com... > How do you ...

Retrieving a sent email before recepient opens it
How do I retrieve an email I sent in Outlook 2000 before the recepient opens it ? Hit the "Do do send" before "I decide tomorrow" button. "dan" <anonymous@discussions.microsoft.com> wrote: >How do I retrieve an email I sent in Outlook 2000 before >the recepient opens it ? Unless you are using an Exchange server, there is no message recall. With Exchange server, your chances are better. However, the best way to retrieve a message is to not send it until you have reread it and decide that this should be sent. --� Milly Staples [MVP - Outlook...

Opening Publisher 98 files in Publisher 2003
I can open some Pub 98 files in 2003 but not others. Large files (~18,000KB) won't open. Small (~50KB) will. I don't have Norton Anti-Virus but do have McAfee Virusscan, Personal Firewall+ & Privacy Service. Any ideas? Did you turn off script blocking? -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "1CRSNC" <1CRSNC@discussions.microsoft.com> wrote in message news:3ABEAE44-7A7E-4692-A854-63B0F665ABF4@microsoft.com... >I can open some Pub 98 files in 2003 but not others. Large files (~18,000KB) > w...

Custom Search Folder
Hi! I would like to know if there is any way to programatically create your own custom Search Folder from an Outlook add-in, and of course, add it's own search criteria (I would like to search after a custom fileld added in certain MailItems). Also, if this is possible, how do I access it afterwards? It doesn't matter if this is done via OOM, CDO or Redemption (or something else?)...is it possible? Thanks a lot, Doru Use the Application.AdvancedSearch method to return a Search object, = then use Search.Save to create the search folder. You will be able to = use a custom field ...