Formatting
Follow these rules when formatting your code:
-
Punctuate your code with blank lines.
-
Keep your procedures to a manageable size—preferably not much more than a single screen.
-
Keep indentation under control. If you’re having difficulty remaining within the right margin, you’re probably nesting too deeply.
-
Use parentheses to enhance the readability of your code. No one reading your code should have to wonder what you meant when you wrote it.
-
Preserve screen real estate wherever possible. For example, when creating a long string, it might be better to build up the string with multiple assignments:
Dim sMsg As String
sMsg = "This is a paragraph that is to appear "
sMsg = sMsg & "in a message box. The text is "
sMsg = sMsg & "broken into several lines of code "
sMsg = sMsg & "in the source code, making it easier "
sMsg = sMsg & "for the programmer to read and debug. "
MsgBox sMsg, vbOkOnly, "Text"
Dim sQRY as String
sQRY = "SELECT Customer.CustomerName, Orders.OrderValue "
sQRY = sQRY & "FROM Customer, Orders "
sQRY = sQRY & "WHERE Customer.CustomerId = Orders.CustomerId"
ReportQry1.SQL = sQRY