Results 1 to 4 of 4
  1. #1
    michaelb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2011
    Posts
    28

    Question Trouble With Variable holding Value


    I have a table, TblCounter, that I am using to setup a counter that is incremented by one each time it is accessed. I store the counter in a variable (myCntVar) which I want to store in a record that already exist in one table (Table A). I also need to create a new record in a different table (Table B) and store the counter in the new record. I am able to store the counter in (myCntVar) in one module, which I tested by putting the variable in a Msgbox (myCntVar) statement which displayed in a form. When (myCntVar) is placed in another module, it does not hold the value place in it. I defined the (myCntVar) as Public at the beginning of a module before the first Procedure so I am able to use it. My Problem is it does not hold the value placed in it. Please Help!!! Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It sounds like a scope problem. To be accessible throughout the application, the variable should be declared in a standard module, not the module behind a form or report. Is it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    michaelb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2011
    Posts
    28
    Quote Originally Posted by pbaldy View Post
    It sounds like a scope problem. To be accessible throughout the application, the variable should be declared in a standard module, not the module behind a form or report. Is it?

    Thanks pbaldy. Your solution worked for me...

    michaelb

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form Not Holding Data
    By batowl in forum Forms
    Replies: 24
    Last Post: 02-18-2011, 12:08 PM
  2. Trouble with (R)
    By NOTLguy in forum Access
    Replies: 3
    Last Post: 10-29-2010, 11:55 AM
  3. Iff trouble
    By JackT in forum Access
    Replies: 3
    Last Post: 08-18-2010, 02:28 PM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums