Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Name Substitution

Status
Not open for further replies.

waypoint

Programmer
Jan 16, 2004
7
0
0
US
I'm stumped due to my lack of VBA skill. See below code...I trying to figure out how to get my string "strControlName" into the control name where I have annotated X.

Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

Dim stDocName As String

stDocName = "Form2"
stLinkCriteria = "[context]=" & Me![X].HelpContextId]

As you can surmise, this is part of a roll-your-own help facility I'm trying to put together...user right-clicks on the control trapped by mouse down event then opens a form which is filtered based on the control which had the focus when right-clicking occured.

Thanks in advance.



 
Hi

you mean like

stLinkCriteria = "[context]=" & Me.Controls("strControlName").HelpContextId]


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

Sincerely appreciate the response. It works great, though I had to remove the " surrounding the variable. Below is the entire sub, though I need to cancel the access event prompted by the right-click (drop down menu) and handle the form name in a similar manner as to the control.

Hopefully, I'm not trying to push the boulder uphill by avoiding the html workshop for help...it's simply not as straightforward as I'd like, and I really do not need the index search or other bells and whistles. My alteranative is that so long as text box has a helpcontextid, a record in a table containing the appropriate help information for that control can be popped. Since it's part of the database, one can slice and dice and report these help components as one wants.

Thanks again,
Jeff

Private Sub System_Name_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

Dim stDocName As String

stDocName = "Form2"
stLinkCriteria = "[context]=" & Me.Controls(strControlName).[HelpContextId]
If Button = 2 Then DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

 
Hi

OK, I thought you had a literal control name, did not realise you had a variable containing a control name, as you say just strip off the ""

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top