I don't know where this way of doing things originated, but I personally find it out of keeping with consistency.
All statements within a block
typically are indented. The Sub/End Sub statements delineate a block. Yet so many people don't indent the On Error statement, and many also don't indent the Dim statements.
Your comment, ' Declares the Object Varibles (sic) only states the obvious. Think about removing the comment. The same with the ' Sets . . . statments.
Try to avoid âMagic Numberâ statements like If Rst.State = 1 ... Use the predefined constants (adStateOpen).
PopulateControlsOnForm is a sub. Don't use Call.
Code:
If Rst.BOF And Rst.EOF Then
Exit Sub
Else ' This else is unnecesary. If the If were true,
' you have already left the Sub. All after that
' is a de facto else...
Rst.MoveFirst ' This is unnecesary. RecSets open to 1st.
PopulateControlsOnForm
End If
If Rst.BOF And Rst.EOF Then Exit Sub
Call PopulateControlsOnForm
...
Rst has local scope only within Sub Form_Load().
Do this:
Code:
...
PopulateControlsOnForm Rst
...
Sub PopulateControlsOnForm(ByRef Rst As ADODB.Recordset)
...