Automating my help text for a datasheet

following on from an earlier question ....

Private Sub SellingPrice_GotFocus()
Me.Parent.HelpTextForField = Me.SellingPrice.Tag
End Sub

Open in new window

This code is used in every field in my datasheet and displays "help" text that is held in the "tag".

I would like to automate a little further as follows;
1. Setup a new tblHelpUsers with two fields ; [Control_Name], [HelpText]
2. So, when the control is in focus I simple call a function "DisplayHelp"
3. The function will KNOW the controlname and set my  Me.Parent.HelpTextForField to [tblHelpUsers].[HelpText] as per the original VBA
4. Obviously I will no longer use the "tag" to hold help text.

What line should I put in my function to achieve the above?

Al contributions appreciated.
Patrick O'DeaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Create a Function that accepts the (a) the name of the Control to supply the Help Text for and (b) the name of the Control where you want to display that text:

Function ShowHelp(ControlName As String, DisplayControl As Textbox)

Dim s As String
s = Nz(DLookup("HelpText", "tblHelpUsers", "Contol_Name='" & ControlName & "'"),"")
DisplayControl = s

End Function

Now call your function like this in the GotFocus or Enter event:

ShowHelp Me.Name, Me.Parent.<DisplayControlName>

Where <DisplayControlName> is the name of the control on the parent form where you want to show the Help text.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I think you might want to make your help table a little more sophisticated.  Rather than just using control name as the unique identifier, I would also use form.  So the help table would be:

FormName (PK field 1)
ControlName (PK field 2)
HelpText (memo)

You might need other fields also so give it some thought.
Patrick O'DeaAuthor Commented:

Your suggestion is work well ... but ...

Me.Name is displaying the form name (I want the control name)

I suspect that this may be because my datasheet is held as a subfolder within another folder.

QUESTION: Is there a better way to reference the actual control?
Patrick O'DeaAuthor Commented:
Got it ;

Patrick O'DeaAuthor Commented:
Thanks folks,

That works perfectly!

(Comments noted, Pat)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.