• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

Access VB spacing code Easy!!

I have tabbed all of my code further to the right, now my boss wants me to move it back to the left.
Even though I know that this does not affect the functinoality of the code whatsoever, I must fulfill her requerst. The code is many pages long all tabbed to the right.

How do I tab all the code back to the left? Is there a way to make all code start from the begining?

Example:

Current Code: (Notice how it is spaced to the right)
                        rst1.Edit
                        rst1![vendor1] = rst![quote_date]
                        rst1.Update
                        rst1.MoveNext

How my boss wants it: (She wants it all at the begining of each row like below)

 rst1.Edit
 rst1![vendor1] = rst![quote_date]
 rst1.Update
 rst1.MoveNext
0
ouestque
Asked:
ouestque
  • 3
  • 2
  • 2
  • +3
3 Solutions
 
Toast_BoyCommented:
In the VBA editor, make sure you have the Edit toolbar visable, this has an indent tool there, so you can select a block of text and move it in and out.
0
 
peter57rCommented:
I think you will have to do it one module at a time but in any module use Edit>Select All and then use the Outdent button as many times as you need.
0
 
Patrick MatthewsCommented:
Hello ouestque,

What an absurd request!  YOur boss does understand that this will make understanding your
code much harder, right?

Select all the text in the module, and keep hitting Shift+Tab until everything is flush to the left.

Regards,

Patrick
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mbizupCommented:
In the VBA Editor, try this:

EDIT -> Outdent

That said, yuck!  The formatting makes the code so much more readable!
0
 
mbizupCommented:
{Sorry for the duplicate post... I *thought* I had refreshed the window before posting}
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>How my boss wants it: (She wants it all at the begining of each row like below)
Just out of curiosity, is your boss a programmer?
Are you a programmer?

Our answer will vary widely based on your response.
0
 
ouestqueAuthor Commented:
Yes we are both programmers, but there is usually a reason why she wants such things done.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
In that case, some possibilities are:
(1)  She wants your programming to match their well-established coding convensions, so later in life they can look at your code an not have to go through any special hoops to understand it.
(2)  She views you as an amateur programmer, and is attempting to train you in her definition of the 'right' way to program.   Since you're even asking this question, the likelihood here is pretty good.

>Even though I know that this does not affect the functinoality of the code whatsoever, I must fulfill her requerst.
Correct.  It has nothing to do with functionality, and everything to do with readability.  
She doesn't want to read your code six months ago and have the first thought be 'Who wrote this pile of cr&p?'

Highlight all code, then hit tab key to indent to the right.  Shift-tab indents back to the left.

VERY common coding practices are to indent everything within a decision structure such as If..Then, For..Next, Do..While, etc.  
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>VERY common coding practices are to indent everything within a decision structure such as If..Then, For..Next, Do..While, etc.  
If you have any doubts here, go to a sub that has six nexted decision structures, then remove all indentations by highlighting all, then shift-tabbing back to the left.  You'll immediately see what I mean.
0
 
peter57rCommented:
To emphasise what Jim is saying, you can buy/download code manager programs which go through code and insert suitable indents for all control structures.  Aligning everything to the left would be regarded by everybody as poor practice, I think.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now