?
Solved

Assign Variable to Textbox Name and Set Visible Property

Posted on 2006-05-05
4
Medium Priority
?
816 Views
Last Modified: 2012-06-21
Can I assign a variable to the name of a textbox and then set the visible property?
My string variable is "strFailCode". I look up the value of Fail Code in a table and then add "txt" to the front of the name.
I then want to turn off the visible property of the textbox in code.
(For example: the first record in the table would be BentPins and the textbox is Named txtBentPins, so my variable would be equal to "txtBentPins")
Using strFailCode.Visible won't work of course, is there a way to let VB6 recognize that strFailCode is the textbox name?
I am new to VB coding.
0
Comment
Question by:maryburgess
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
jet46 earned 200 total points
ID: 16617961
You can do this by:

Forms!FormName!(strFailCode).visible = false
0
 
LVL 5

Expert Comment

by:jet46
ID: 16617964
By the way, where i put "FormName" in my last comment, you need to type the actual name of the form.
0
 
LVL 58

Expert Comment

by:harfang
ID: 16621894
Hello,

jet46 is basically correct, but there is a typo: an additional !
From the form itself, use:

    Me(strYourVariable).Visible  = True  ' which is a shortcut for
    Me.Controls(strYourVariable).Visible = True

Cheers!
(°v°)
0
 

Author Comment

by:maryburgess
ID: 16631193
The answer from jet46 worked great as written. Thanks to both of you for the response!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 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