Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003

    Question Unanswered: module level variable

    I want to create a customer ID field in a table as an autonumber that will link the customer table to other tables but I want the rest of the customer information to be input with a form. I want to be able to then using a query, update the customer info and save the ID number as a variable to be used by subsequent forms which will also update with a query. Any suggestions?

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    if you want to share a value amongst multiple forms AND you cannot guarantee that one particular form will always be open during the sharing, you need a global variable.

    last item on the left of your database window Tables/Queries/Forms...... is Modules.

    new module

    global myGlobalVariable as long 'or whatever it is

    downside of modules is that the first reference to a sub/func/var/const in a global module loads the entire module into memory and it stays there until you quit the application you should try to minimise the number of globals you use.

    if you do have a form that will always be open during the sharing process, it is tidier to put your shared variable on that form (when the form is closed, memory is cleared). at the top of the code, just before the first sub/func use
    public myPublicVariable as long 'or whatever


  3. #3
    Join Date
    Sep 2003


    I could actuall set the visible property of the customer info form to false so that way the value in the customer ID field is still in memory. What I needed was how to declare the variable which is public. Thank you for jogging my memory. I used to program in access for a job but being out of work for a year you get rusty.

Posting Permissions

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