I took over an old Access project and have been going through the code. I have no formal development training - my skills come from a lot of experience.
Can someone explain the benefits of using "stDocName" in the following code?
My question is, why wouldn't you just use:
I'm sure there's a good reason, but like I said, I never had any formal training, so the benefit isn't immediately apparent.
Further, you'll notice that the previous developer didn't bother to provide meaningful names to any of the form controls - so, clearly, they took shortcuts in some places and not others. Since I'm not familiar with the benefits of applying the string to the DoCmd.OpenReport method, I don't know if this is one of those shortcuts that I should ignore, or if this is good programming practice that I should start using so future developers won't look on me with disdain.
Can someone explain the benefits of using "stDocName" in the following code?
Private Sub Command122_Click()
On Error GoTo Err_Command122_Click
Dim stDocName As String
stDocName = "rptInventory"
DoCmd.OpenReport stDocName, acPreview
Exit_Command122_Click:
Exit Sub
Err_Command122_Click:
MsgBox Err.Description
Resume Exit_Command122_Click
End Sub
My question is, why wouldn't you just use:
Docmd.OpenReport "rptInventory", acPreview
I'm sure there's a good reason, but like I said, I never had any formal training, so the benefit isn't immediately apparent.
Further, you'll notice that the previous developer didn't bother to provide meaningful names to any of the form controls - so, clearly, they took shortcuts in some places and not others. Since I'm not familiar with the benefits of applying the string to the DoCmd.OpenReport method, I don't know if this is one of those shortcuts that I should ignore, or if this is good programming practice that I should start using so future developers won't look on me with disdain.