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
Solved

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

Posted on 2011-03-06
5
286 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

860 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