Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    108

    Unanswered: public variables

    is there a way i can create a variable that can be accessed from any form at any time?

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Put it in a module ... Modules are available to all forms at any time ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    As a reminder to yourself that it's public, use PUBLIC instead of DIM when you dimension the variables.
    Code:
    PUBLIC pubStrVar As String
    PUBLIC pubIntVar As Integer
    etc.
    For even more fun, you can use PUBLIC Subs and Functions in the modules as well.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  4. #4
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    j walker,

    What I do for my public variables, so they will ALWAYS be available, is put them on a hidden form this is always open. This way, for example, when I get a start and end date from the user for a report, I put those dates into the hidden form, and then have the query that feeds the report look for start and end dates in the hidden form. When testing a report, I don't have to keep keying in the start and end dates either. When something bombs, and it always does, I have all my public variables available for help in debuging my code. If you are talking about variables that are only used in VBA code, and will not be used in forms or reports, those are the one that I define as Global, or as Public.
    HTH,

Posting Permissions

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