index > Visual Basic for Applications (VBA) > Global Variable not Persisting

Global Variable not Persisting


Hi there, i seem to have hit a BIG problem! Im building a new system for users at work and the functionality of the system so far is good. However a lot of the functionality is based on permissions applied to the user after they have logged in - there is a global variable that stores every users login name 'loginname'. However at some point, (although not always) if the user is doing a lot of work in the system by entering activity, creating companies, contacts etc then they will receive a message stating 'Error 94: Invalid use of null' and when I go to debug it will highlight a line of code that inevitably depends on the 'loginname' global variable. I have a little text box that holds the loginname after the user has logged in and it will disappear from there after the error message so it seems that the global variable is not persisting for the duration of the users login. Does anyone know why this might be the case? The main problem is i know why the error message appears but there seems to be no consistency in being able to replicate a scenario in which the global variable is dropped.

Can anyone help!?

Thanks,

Rhys.

RhysDavies

Are you declaring the variable in a "normal" module rather than a class module?




a little trolley is a dangerous thing for example you could trip over it
duck thing

Hi Duck thing - thanks for that but yes i am - i have now found out what is happening - there were a couple of pieces of code that did not have event error handling so when i cancelled a feature that had no event error handling im guessing the variable would then destroy itself - i have added error handling to the relevant 2 pieces of code and the global variable now persists until the user ends his session.

Thanks again,

Rhys.

RhysDavies
reply 3

You can use google to search for other answers

 

More Articles

• Generating Outlook Appointments from database
• Access and VBA application in the mdb file
• Output Parameter in Excel VBA
• Passing new parameters to rdlc reports
• Create ProjectItem Error. (Core API)
• Wildcards in a "Save As" path string
• Run time error 1004
• Hyperlink to a subroutine
• Defining a range according to the number of responses
• Commandbar ICon (Excel VBA )
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• When to program in VBA and when not to???
• last Modified date in Excel spreadsheet
• Copy Outlook email into Excel
• Avoid message boxes during macro?
• PPT command button link to other pres
• webservice toolkit and complex types
• Excel VBA using ADO
• How to open Access files and export them
• macro in .xml
• Dynamicaly enter Data in Microsoft Access
• unable to register comsvcs.dll
• Excel Pivot Tables - Dynamically Changin
• programming changing of property
• Excel ShapesText
• Odd or even and converting Decimal to bi

Hot Articles

• VB Control Air card sent file to GPRS
• How Ms/Access can display linked UTF-8 s
• XP style appearance
• autocomplete
• Run time error 1004
• Method 'OnAction' of object 'CommandBarB
• VBA Excel - Using FindNext
• worksheet_change and data validation
• Access Frontend vba changes
• Please help me to print the label for th
• unembedding Excel in Internet Explorer
• Can anybody explain this code for me ???
• .lookin =
• getting web pages from VBA?
• Function which get range arg.

Recommend Articles

• Increase Speed of a Word Macro
• Retrieve IBM Workplace Forms data into E
• Pull data from .csv files into one main
• New to VB
• Generating Outlook Appointments from dat
• Suppress Linked View Unique Record Popup
• paste values from multiple sheets to ano
• Command Buttons
• Argument syntax problem
• Trying to create Data Acess Pages to man
• VBA in EXCEL - Connect to SQL Server
• [URGENT] Need Help for "Error 1004:
• Office Word Macro - create file to a spe
• Extract text within several tables in wo
• Need VB6 Code to direct sound waves to c