Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    declaration of string (Access 2000)

    In all my function in the form i am declaring a string like that : Dim StrSQL As String. This is valid however only for the private function and not for all the functions in my database.Can i declrae the string StrSQL once and for all applications in the database?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: declaration of string (Access 2000)

    You can, but in general, you shoulddeclare a variable at the level where it is needed. If you only use the value of StrSQL within the function (or porcedure) itself, it is best to declare it there. If you need to set the value of StrSQL in one function but use it in another function, you can declare the variable at the top of the module as a private variable. You can use StrSQL in all functions/procedures within the same module.

    Private StrSQL As String

    Private Sub ...()
    ...
    End Sub

    Private Function ...()
    ...
    End Function

    If you need to set the value of StrSQL in a function in one module and use that value in other modules, you can declare the variable at the top of a standard module (created by selecting Insert | Module in the Visual Basic Editor) as a public variable. You can use StrSQL in all code within the database.

    Public StrSQL As String

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •