Solved

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

Posted on 2011-03-06
5
275 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
  • 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 84

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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.

770 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