Access Visual basic Statement in statement How To

Posted on 2013-01-29
Medium Priority
Last Modified: 2013-01-29
Microsoft Access Visual Basic 2007

I have this:

S2 = "[" & Me.Select1 & "]"
Forms!main.Form!Data.S2.ColumnHidden = False

Notice, i'm trying to use the S2 in the second statement.

But this won't work, can someone please provide a suggestion about how to go about this?
Question by:Ursino
  • 2
LVL 22

Expert Comment

ID: 38832665
Did you try it without the &'s?

S2 = "[Me.Select1]"

LVL 50

Accepted Solution

Dale Fye earned 2000 total points
ID: 38832672
Try something like:

Forms!Main!subformControlName.Form.Controls(me.Select1).ColumnHidden = False

I assume you are trying to unhide a column in a datasheet that is being used as a subform on you main form.  Where is this code firing from?  Is it a control on the main form?  If so, you should be able to use something like:

me.subformControlName.Form.Controls(me.Select1).ColumnHidden = false

Note:  subformControlName refers to the NAME of the subform CONTROL, not the name of the form that is the SourceObject of the subform.

Author Closing Comment

ID: 38832753
This worked like a charm, all assumptions made were correct.
LVL 50

Expert Comment

by:Dale Fye
ID: 38832799
glad I could help.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

624 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