Link to home
Start Free TrialLog in
Avatar of shaun37
shaun37

asked on

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

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??
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

You mean like this:

Private Sub Command3_Click()

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

?

mx
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shaun37
shaun37

ASKER

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

Avatar of shaun37

ASKER

Increasing points - really need someone to take a second look....
Avatar of shaun37

ASKER

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