Does it matter? (1 Viewer)

Angelflower

Have a nice day.
Local time
Yesterday, 18:45
Joined
Nov 8, 2006
Messages
51
The database I am working on has Access as the frontend and SQL as the backend. I have noticed that both peices of code will work. I want to know if it really makes a difference in which one I use.

Dim stDocName As String

stDocName = "rpt_MAMC_invoice"

DoCmd.OpenReport stDocName, acPreview

or

DoCmd.OpenReport "rpt_MAMC_invoice", acPreview
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:45
Joined
Aug 30, 2003
Messages
36,126
I think it's personal preference. My tendency is towards the second method, unless I'll need the variable for other things. There would be a slight performance hit on the first method, but realistically it wouldn't be noticeable. I'm just lazy. :p
 

Angelflower

Have a nice day.
Local time
Yesterday, 18:45
Joined
Nov 8, 2006
Messages
51
Yeah that is what I was thinking... less typing...
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:45
Joined
Jan 20, 2009
Messages
12,852
All of the extra waffle is a product of Microsoft Access Help. Some developers continue to use it because they don't understand that it isn't necessary.

The only really good reason to use a variable is when the value is assembled with concatentation and you want to see the result before it is applied to the command. For example when generating an SQL string. Without the variable there is no way to see the resulting SQL when you are trying to debug the procedure.
 

Users who are viewing this thread

Top Bottom