R
robert d via AccessMonster.com
I have a subroutine as follows:
MySub(Var1 As String, Var2 As String, Optional Var3 As String)
The subroutine builds an SQL statement based on the variables passed to it. I
want to make sure that I'm using good practices in dealing with the optional
variable.
So if no Var3 is to be passed, then do not pass a value to Var3.
Call MySub(strVar1, strVar2)
In this case Var3, in the subroutine, will equal "" (no spaces). So in code
that builds the SQL statement, I would have the following:
If Var3 <> "" Then
strWHERE = strWHERE & "Additional Where clause"
End If
I just want to make sure that there won't be any unintended or unforseen
consequences of the way I'm handling this.
Thanks.
MySub(Var1 As String, Var2 As String, Optional Var3 As String)
The subroutine builds an SQL statement based on the variables passed to it. I
want to make sure that I'm using good practices in dealing with the optional
variable.
So if no Var3 is to be passed, then do not pass a value to Var3.
Call MySub(strVar1, strVar2)
In this case Var3, in the subroutine, will equal "" (no spaces). So in code
that builds the SQL statement, I would have the following:
If Var3 <> "" Then
strWHERE = strWHERE & "Additional Where clause"
End If
I just want to make sure that there won't be any unintended or unforseen
consequences of the way I'm handling this.
Thanks.