Global Variable and Form 
Author Message
 Global Variable and Form

All global variables are erased when i open a form !!!!
Is someone could say me why?

I have :
 Access 97

Variable :
 All global are in one module
 Public variable as String 'for examples

I launch a code a the launch of my database (Macro Autoexec - Runcode)
which load from a table all global variables

Form:

 all my forms are created by  docmd.runcommand accmdnewautoform
 i save them with docmd.save acform, "frmTest"

When i launch a form
   All global variable are erased before each event sub
("OnOpen","OnClick"..)

Have i commit a mistake ? (or is it Bill?)

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 06 Jan 2003 03:00:00 GMT  
 Global Variable and Form

Make the variables static.

Static variablename as type

Or use Constants instead of variables for the values loaded from the table.

Sean Marsell



Mon, 06 Jan 2003 03:00:00 GMT  
 Global Variable and Form
These global variables are defined in a standard module, not a form module?
If so, then they should retain their values unless something you're doing is
causing the project to be reset.  If they're in a form or report module,
then they will lose their values every time the form or report is closed.

--

Dirk Goldgar
(remove NOSPAM from reply address)

Quote:

> All global variables are erased when i open a form !!!!
> Is someone could say me why?

> I have :
>  Access 97

> Variable :
>  All global are in one module
>  Public variable as String 'for examples

> I launch a code a the launch of my database (Macro Autoexec - Runcode)
> which load from a table all global variables

> Form:

>  all my forms are created by  docmd.runcommand accmdnewautoform
>  i save them with docmd.save acform, "frmTest"

> When i launch a form
>    All global variable are erased before each event sub
> ("OnOpen","OnClick"..)

> Have i commit a mistake ? (or is it Bill?)
> Thanks

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 06 Jan 2003 03:00:00 GMT  
 Global Variable and Form
Can you tell us why you think they are gone? What happens if you press
Ctrl+G to open the debug window and then type
? myVariable [press enter]
Try this at several stages of your application to see where you are losing
the values.
Duane
Quote:

> All global variables are erased when i open a form !!!!
> Is someone could say me why?

> I have :
>  Access 97

> Variable :
>  All global are in one module
>  Public variable as String 'for examples

> I launch a code a the launch of my database (Macro Autoexec - Runcode)
> which load from a table all global variables

> Form:

>  all my forms are created by  docmd.runcommand accmdnewautoform
>  i save them with docmd.save acform, "frmTest"

> When i launch a form
>    All global variable are erased before each event sub
> ("OnOpen","OnClick"..)

> Have i commit a mistake ? (or is it Bill?)
> Thanks

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 06 Jan 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Pass global variable from form to form

2. Global Variable between forms?

3. Global Variables through forms

4. Global Variables / Global Objects

5. using global variables in different forms

6. Forms and Global Variables - how to use them?

7. GLobal Variable + Form bug?

8. Global Variables for multiple forms

9. Problems with VB modal/modeless forms and global variable

10. Forms and Global variables

11. Problems with VB modal/modeless forms and global variable

12. Multiple forms with global variables

 

 
Powered by phpBB® Forum Software