Solved

How to reference the Tag of a custom button on a shortcut menu (Access2000)

Posted on 2011-03-06
5
301 Views
Last Modified: 2012-08-13
I have a form with a textbox (memo) that is tied to a shorcut menu with custom buttons.  

How do I reference the tag on the custom button when it gets clicked??
0
Comment
Question by:shaun37
[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 75
ID: 35050452
You mean like this:

Private Sub Command3_Click()

    Dim sTag As String
    sTag = Me.Command3.Tag
   
End Sub

?

mx
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 300 total points
ID: 35055237
I believe it's like this:

Application.CommandBars("YourShorcutBarName").Controls("YourButtonName").Tag

If the Button is on a SubMenu, you'll have to work down through those as well, using the same basica syntax.

You can also use the FindControl method with Recursive = True to have VBA locate it for you:

Application.Commandbars("YourCommandBar").FindControl(xxxx)

This link might help:
http://msdn.microsoft.com/en-us/library/aa171234(v=office.11).aspx

Working with commandbars:
http://msdn.microsoft.com/en-us/library/aa141022(v=office.10).aspx





0
 

Author Comment

by:shaun37
ID: 35083358
I've tried to make each of your suggestions work but it isn't happening.  I'm attaching a code snippet and a sample db.   SampleDb.mdb
Function TagThis()
Dim ctl As Control
Dim StartPos As Long
Dim PostInsert As String
Dim PreInsert As String


Set ctl = Screen.ActiveControl
StartPos = Forms!frmSample.txtMemo.SelStart

  If Not IsNull(ctl) Then
    PreInsert = Left(ctl, StartPos)
    PostInsert = Right(ctl, Len(ctl) - Len(PreInsert))
 
   'Instead of:
    ctl = PreInsert & "<p>" & PostInsert
   
   'I would like:
   'ctl = PreInsert & [the selected custom command button TAG here] & PostInsert
  
  End If
 
 ctl.SelLength = 0
 Forms!frmSample.txtMemo.SelStart = StartPos
       
End Function

Open in new window

0
 

Author Comment

by:shaun37
ID: 35094568
Increasing points - really need someone to take a second look....
0
 

Author Closing Comment

by:shaun37
ID: 35094906
LSM,
  Wait!!  It just worked!  The problem was that I had the value of the tag set the same as the name of the tag control.  It was looking for a tag called "<p>" equal to the value of "<p>" and it didn't like that.  When I changed the the tag name to "MyTag" it worked beautifully.

I've been looking at this for tool long.  Thank you kindly.  They're all yours.

Shaun
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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

718 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