Setting Variables
Hi,
I have a form module that runs a lot of SQL code in several different subs.
I often call ALL my string SQL variables strSQL, so my subs look like this:
Sub A()
Dim strSQL as String
strSQL = “abc”
…run sql code
End Sub
Sub B()
Dim StrSQL as String
strSQL = “xyz”
…run sql code
End Sub
Instead of using Dim in every Sub, however; I sometimes do this:
Option Compare Database
Option Explicit
Private strSQL As String
----------------------------
Sub A()
strSQL = “abc”
…run sql code
End Sub
Sub B()
strSQL = “xyz”
…run sql code
End Sub
I wonder, however, if I should “reset/clear” the variables myself at the end of every Sub, like this:
Sub A()
strSQL = “abc”
…run sql code
strSQL = “”
End Sub
Sub B()
strSQL = “xyz”
…run sql code
strSQL = “”
End Sub
Any thougts? Is that a good idea?
Thanks,
alex