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

Similar Articles

[PageSpeed] 31

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:

Use Form to prompt for report criteria
I have a form that I am using to prompt for report criteria. When I run the query outside of the form, it works fine - prompting me for both criteria. However when I run from the form, I get #Error#. Can you see what I am doing wrong? Thanks in advance. I have two combo boxes that I have put in my underlying query. In the fields of the query are: [Forms]![frmSelection Criteria Form]![OfficeNumber] [Forms]![frmSelection Criteria Form]![Manager] *** On the OnClick event is the following: Private Sub Command6_Click() On Error GoTo Err_command6_Click Dim stDocName As String st...

3.0 Customization
Is it possible in 3.0 to have one set of screens appear for one group of users and another set for another group. For instance, could our service people only see the service screens while our sales people only see the sales screens? I know I can restrict access to different areas, but we want to have a totally different look and feel for each group... Sorry - I dont believe this can be done "Matt Harvey" <rifleman@gmail.com> wrote in message news:OR2vU$3GGHA.740@TK2MSFTNGP12.phx.gbl... > Is it possible in 3.0 to have one set of screens appear for one group of >...

moving payables data from open to history
Hello: A client says that someone imported data about a year or two ago into Great Plains from their AS400. Many payables documents that were imported should have been coded during the import as open, instead of history. The client knows that she can take care of this herself within two hours, by simply turning off the posting to the GL and entering and posting the payables documents to move them to history. But, she is wondering if there is a quick and easy way to do this on the back-end. I'm familiar with the open and history payables tables within GP. And, I know through a T...

SharePoint (WSS) 2007 / Outlook 2007 - Alert
This is a multi-part message in MIME format. ------=_NextPart_000_00AD_01C70E47.83B45950 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable We have setup a SharePoint Server (WSS) 2007 and are using the alerting = functionality. After we changes stuff on WSS, an alert message is generated and sent to = an email account. This e-mail account is hosted on an Exchange 2003 server. When using Outlook 2007 to open the e-mail, we get: Cannot open this item. Wenn using OWA the e-mail can be opene fine. Does somehow have an explanation for th...

Insert,Update Data in sage (MS Access Linked tables) using Vb.net form
Hi folks, I am developing application using vb.net which requires integration with SAGE LINE 50 (Accounting software ) V11... The data which SAGE is using is MC ACCESS 2003 database... with linked tables in it... Now I Have developed the Sage connection using ODBC which works fine when reading the record but cannot Add or Update record into the Linked tables.... When i debug the program the error is at the line where it has... <br> MyodbcCommand.ExecutenonQuery() <br> Can anybody Help ????? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/acce...

disable Review toolbar which came up automatically when opening a.
How can I disable the Review Toolbar which comes up automatically when opening a file? In the Workbook VBA actions. The top left hand corner there is an Excel logo, not the one in th blue program bar, but in the menu bar. Right Click and select "View Code" There will be two drop down boxes one that will probably say General if this has never been entered previously. Change the box on the right to Workbook. Then Change the right hand box to "Activate" Insert the following code Application.CommandBars("Reviewing").Visible = False exit the VBA screen and t...

"the wizard is unable to open your query in datasheet mode, possi
"the wizard is unable to open your query in datasheet mode, possibly because another user has a source table open in exclusive mode. your query will be opened in design view" what this message mean ,and how can i solve it Hi - Please provide more details as to what you are doing when you get the error, what your database setup is (i.e. split Fe/BE?, multiuser?, version? etc). Without more information, we can only guess. Thanks - John amr wrote: >"the wizard is unable to open your query in datasheet mode, possibly because >another user has a ...

too many "inherited" custome headers and footers
It seems that somehow I have "inherited" custom headers and footers from someone else's workbook. They have filled up almost all the allocated spaces in the drop-down selection list and pre-empt me from adding more than two custom headers/footers of my own. I need to add at least four new custom headers to the list. Is there some way to delete all the "inherited" custom headers and footers? Thanks, JR ...

Filling Web Form
Dear freinds Hello, I have written code in vc++ using MFC to fill the Webform using HTTP post method and I'm able to fill the form but I'm facing a problem that I'm unable to fill login name and password. So any one amongst you have any Idea or help then please help me With Regards Sachin ...

Add new record through Form view
I have a table which is linked to a form, i would like to have a command button which will add a new record to my table. On the click of command button it should view the last empty row of my table in a form. On Sat, 26 Dec 2009 11:11:01 -0800, Ranjith Kurian <RanjithKurian@discussions.microsoft.com> wrote: >I have a table which is linked to a form, i would like to have a command >button which will add a new record to my table. >On the click of command button it should view the last empty row of my table >in a form. The Click event should show [Event Proced...

CRM 4.0 Custom Report Filter Problem
I am using the Report Wizard to create a simple report. Report is using Quotes and Quote Products I have a custom field in Quote Products which is a bit field Yes-No When I use that field as a filter for report output, I get all records. The filter criteria appears to be ignored Is this an inherent problem with Report Wizard or Am I doing something wrong? Thanks. depends on your business logic and what you want to see. If you have three quotes: Quote-1 has three products, all with the custom field set to Yes Q2 has three products, two set to Yes, 1 to No Q3 has three products, all set...

Excel 2000 vs. Excel 2002
I am having troubles with a workbook that I created that is havin problems opening. I created it in 2002, and it opens fine in Excel 2002 for other people However, when I send it to someone who has Excel 2000, it takes over a hour to open. Now I also made a very similar report that works just fine whe trasferred to excel 2000. Here are a couple of stats on the workbook that is having problems: 1.5mb 500+ externel links 500+ subtotals 200+ simple calculations (a1+b1; a1/b1;etc..) 1 Worksheet in the book. 2 columns with conditional formatting Thanks, Joh -- Message posted from http://ww...

Customizing Excel's Border Defaults
I'm working with Excel 2000 and use Borders frequently. The preset default border is a thin line, yet I prefer and always change it to the thick line. How can I change the Excel default to the thick line rather than the thin line? I know it's a small problem, but it's driving me crazy changing it all the time. In WORD, I know how to easily "add style default to template", but can't figure it out in Excel. Any help is greatly appreciated! ...

Can you create custom activities? MSCRM 3.0
Hi, Is there a way to create a new custom activity instead of customising an existing one? I have created a custom entity called 'Chat' utilising an IFRAME. All works well but this entity really should be an activity considering it's properties. In fact I've just been introduced to MS-CRM 3.0 and don't really understand what the difference is between an entity and activity. Would anyone shed the light for me? BTW, I think 3.0 looks great. Gotta admit it's improved. Cheers. Ty In my experience, you cannot create custom activities. In fact, I have been dire...

Office 2004 issue with documents NOT BEING ABLE TO OPEN APPLICATION, but application can open documents.
BACKGROUND: Just migrated all my files and apps from a G4-400 to a new Mac Mini 1.87ghz Intel running pre-installed OSX10.4.10. Used CD to install 'normal' version of Office 2004 Mac on the new Mac Mini. In fact its the same disk that I used originally to install Office on the G4-400. PROBLEM: Neither old .xls and .doc documents (made on old Mac, nor new .xls and ..doc documents (made on new Mac)will not open their respective applications, when clicked upon. ADDITIONAL INFO: However, when I use either of the the application's "Open" feature, theres is no pr...

Opening .prn files in XL2000
I am using a software that does not save data/reports in .csv or .xls formats; only in printed versions. Is there a way to save the printed report in a file and open the file in XL2000? If there is, how is the print file produced, where is it saved, etc? A friend suggested setting up a generic printer but didn't know how to go about it. You may want to give that other software just one more chance--look under File and see if there is a SaveAs option. You may find something upon further review. But if you want to add a generic printer, I think it'll depend on your version of win...

Trying to open the current db in Access 2010 through Access Basic
I haven't programmed in Access Basic in quite a long time. Through Access Basic coding, I use to be able to open the current database and then open a table and walk through each record. Now I can't even open the database. Does anybody have an example of how to do the following: 1) Open Workspace 2) Open Current Database (assume name is unknown during run time 3) Open specific table 4) Step through each record and access the fields George C. Derkacs <George C. Derkacs@discussions.microsoft.com> wrote: >I haven't programmed in Access Basic in quite a lon...

MS Access 2007, Forms
When using the "Forms Wizard", I need to use the "Style: Ricepaper", but it isn't available in the 2007 version and I have not been successful trying to find it in Office Online or on the web. Does anyone know where I can get it? Access 2007 has 25 AutoFormats, but as you noticed, they are virtually all new ones. It's actually nice to see that these were updated. To get the older Ricepaper style you could probably create a form in an earlier version of Access and then import it into your current database. If you're using the ACCDB file format, you would...

Where can I get a good holiday booking form for my golf business?
I need a quality Booking Form for my Golf Holiday business on the Costa Del Sol. One which includes sections for accommodation, dates, numbers, flight enquiries and car hire enquiries. Any help would be much appreciated on a tight budget. Thanks Dave Wrong forum. Try templates or doing it yourself. :-) -- Russell Dawson Excel Student Please hit "Yes" if this post was helpful. "Dave" wrote: > I need a quality Booking Form for my Golf Holiday business on the Costa Del > Sol. > One which includes sections for accommodation, dates, numbe...

Help
Hi... I tried to work on Word today for first time on newish Mac and realized none of my Office applications work. When I double click on Word I can see something happening as I get the circle of colours twirling, but half an hour later it still hadn't opened. I just have to do this as quickly as possible as I have a deadline for what I have to do Monday at 12. I've tried reinstalling the software, but that didn't do anything for me. Mind you I know absolutely nothing about installing anything on Mac computers so I could be doing it all wrong. Do any of you have any idea what c...

Object error when trying to print custom reports
I am getting an [object error] message when trying to print custom reports or modified versions of canned reports. They display just fine within CRM, we just can't print them. I have already tried deleting the ActiveX to force a reload and manually reinstalling it using http://crmserver/viewer/activexviewer/en/npviewer.exe with no luck. This is occuring on systems regardless of whether Crystal Designer is loaded. Any ideas? Open the reports in Crystal that you are having problems with and make sure that the "Save data with reports" option is not checked. (In Crystal...

Paying customers commissions
The next release should provide the ability to pay customers a commission without having to create a vendor card for them in payables management. My company currently has thousands of customers that we pay a commission to and it gets quite frustrating considering all the redundant data we have to store since our customers have to be setup as vendors also. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the b...

how2 create identity column on contact form
how to use identity contact_id column on sql contactbase table, because i want to, auto increment id field with contactid The ContactId field is defined as a uniqueidetifier (ie. GUID). When you create records via the SDK calls, this value will be assigned for you automatically. I would not recommend going directly against the tables to create records. "tashtan" <mehmettastan@gmx.net> wrote in message news:e44cBjtoDHA.2868@TK2MSFTNGP09.phx.gbl... how to use identity contact_id column on sql contactbase table, because i want to, auto increment id field with contactid ...

Different field control sources for unbound form
Hi. I'm using Access 97. The short description of my problem is: I have an unbound form named Stats1. On the form I have 3 text boxes (AvgofR1, AvgofR2, and AvgofR3). There are 3 "total queries" (Q1, Q2, and Q3) that when run return an average in a field called AvgofR1 for query 1, AvgofR2 for query 2, and AvgofR3 for query 3. How do I get the value of AvgofR1 from query Q1 to appear in the text box AvgofR1, the value of AvgofR2 from query Q2 to appear in the text box AvgofR2, and the value of AvgofR3 from query Q3 to appear in the text box AvgofR3 on the unbound form Stats1...

Using Word To Design Survey Forms
We already have a form generated in Word to manually collect data. We want to use this form as the basis of a Sharepont survey. I know I will need to crete fields in SP to collect data but importing the word file(16 pages) as a basis for the survey form could save a lot of time Trevor SharePoint has a webpart designed for surveys. Give it a try. --rms www.rmschneider.com On 19/01/10 00:07, Trevor Aiston wrote: > We already have a form generated in Word to manually collect data. > > We want to use this form as the basis of a Sharepont survey. > >...