?
Solved

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

Posted on 2011-03-06
5
Medium Priority
?
306 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 1200 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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