Results 1 to 5 of 5

Thread: public variable

  1. #1
    Join Date
    Sep 2005
    Posts
    28

    Unanswered: public variable

    Hi,

    If I set public variable in Modulus, can I access the variable in forms environment?

    In modulus environment:

    dim run as integer


    is it public variable?

    Please let me know, thanks.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    If the variabel was declared within a Database module then Yes. The run variable will be valid in all forms, reports, and their own respective modules.


    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you declare it as
    public myvar as vartype
    eg
    public booStatusFlag as boolean

    Generally public vars should be avoided, (unless of course there is absolutlely no way of completing the task). The main problem is that any function or sub routine in any open form / report etc can modify the contents of a public varaiable. Unless you are discplined in your use of public vars then there is a risk of introducing subtle hard to eliminate errors where several functions are updating the same var.

  4. #4
    Join Date
    Oct 2005
    Posts
    3

    Not working

    I created a module and declared a global variable as
    Global languageselect As Integer

    Within code I can access the global variable.

    How do I display this value in a text box? When I try languageselect as the control source I get #Name.

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    I created a module and declared a global variable as
    Global languageselect As Integer

    Within code I can access the global variable.

    How do I display this value in a text box? When I try languageselect as the control source I get #Name.
    If running from code within a Form module then:

    Me.myTextBoxName = languageselect

    If running from any module other than the Form Module (like a database module) then:

    Forms![myFormNameWhereTextBoxIs].[myTextBoxName] = languageselect

    This is assuming of course that you declared the variable as PUBLIC within a Database Module. Such as:

    Option Explicit
    Public languageselect As String


    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


Posting Permissions

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