Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Visual Basic Code?

Status
Not open for further replies.

vlingen

Programmer
Aug 4, 2006
31
US
My project has a primary form that is launched at startup of the MS Access 2000 application. On this initial form, I define some Global variables. When that happens the Visual Basic window opens exposing all the underlying code to the end user. Is there a way to hide this?

Thanks!
 
Yes, distribute your project as an .mde.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
How are ya vlingen . . .
vlingen said:
[blue]On this initial form, I define some Global variables. [purple]When that happens the Visual Basic window opens[/purple] . . .[/blue]
Really! [surprise]

[purple]Just how are you assigning the variables?

[/purple] ... I can't see this happening unless its thru code, and even this makes no sense!

Normally somewhere in code you'd have something like:
Code:
[blue]   GlobalVariableName = Me!TextboxName[/blue]
[blue]Your Thoughts? . . .[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I think you may have put a breakpoint in some code that is running in initialization, causing the VBA window to open. Or you have an error and it is trying to go into debug.

Joe Schwarz
Custom Software Developer
 
I set a "login" form and when they press the OK button it calles a module "GlobalVar" which has:

Option COmpare Database

Public StrRights as String
Public pTerminal as string


and that's it.
 
vlingen . . .

You should be calling a routine or function within the module.

Post the button code!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I'm still having the same problem, but here are some things I tried...

I created the mde, but get an error when it tries to define the Public variables in the module.

I tried moving the Public statements into a function of the module - error there too. You can't define a Public variable within a function.

So I guess what I need right now is some suggestions on how to define a public variable (one that is available across all forms).

Essentially what I'm doing is when the user logs in via a login form - I store their privilege levels so as I open other forms I know what objects to enable.

Any suggestions would be great!
Thanks.

 
can you show the declaration of the variable, the code where the value of the variable is set. There must be something else going on because there is no reason you can not call a global variable. Global variables are now declared as public (although global is still supported, it is losing favor)

I am sure you are already doing this but it should look like

option explicit
option compare database

public someVariable as string
public someOtherVariable as integer
....

and then anywhere in the code on any other subroutine you should be able to use the variable. Ex:

someVariable = me.someTextField.value
msgbox somevariable

 
On the OnOpen of the Login form I call the Module...

DoCmd.OpenModule "GlobalVar"

The only thing in the module is:

Option Compare Database

Public StrRights as String
Public pTerminal as string

Then the User enters in the User name/password press OK button. The VB window opens before the user does anything.

 
There is no reason to open the module. That just opens the module window. Remove the docmd .openmodule
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top