Public variables: memorized values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PhilippeM
    New Member
    • Aug 2008
    • 15

    Public variables: memorized values

    Hi everyone!

    I have defined 3 public variables:
    Code:
    Public OldCompany As Variant
    Public OldLast As Variant
    Public OldFirst As Variant
    A procedure defines those variables:
    Code:
    OldCompany = !Company
    OldLast = ![Last Name]
    OldFirst = ![First Name]
    Now I would like to retreive those values for the variables in another procedure, in another form:
    Code:
    With rs1
          .Index = "PrimaryKey"
          .Seek "=", OldCompany, OldLast, OldFirst
    For some reason, VB tells me those variables are empty, although, they should have been defined by the other procedure.

    Could someone help me please?
    Thank you!

    Philippe
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. Are the Variables Declared in a Standard Code Module and not a Form or Report Module?
    2. Is the Procedure defining those Variables executed before an attempt is made to retrieve their values?

    Comment

    • PhilippeM
      New Member
      • Aug 2008
      • 15

      #3
      I had them defined in the standard code module, but I overlooked that I had also defined them as a dim variable in the code of my private procedure. That ofcourse is the reason why it didn't work. It all works perfectly fine now.

      Thank you.

      Philippe



      Originally posted by ADezii
      1. Are the Variables Declared in a Standard Code Module and not a Form or Report Module?
      2. Is the Procedure defining those Variables executed before an attempt is made to retrieve their values?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by PhilippeM
        I had them defined in the standard code module, but I overlooked that I had also defined them as a dim variable in the code of my private procedure. That ofcourse is the reason why it didn't work. It all works perfectly fine now.

        Thank you.

        Philippe
        Gald you figured it out, PhilippeM. Procedural Level Variable Declarations will always override Public Declarations.

        Comment

        Working...