Setting a public variable

indesisiv

Access - What's that?
Local time
Today, 15:38
Joined
Jun 13, 2002
Messages
265
Hi there I am sure that i am just having a daft Friday problems but ...

I am declaring a public variable in a module

eg Public IDLetter As String

and i want to set it to a value when the database starts.

How can i do that?

At the moment i am setting it on a form open. Is there a different way to do this.?

Thanks all
Steve
 
My preference is to make a function called Main() in a module.

I make a macro called autoexec that runs as the database is opened. The macro's only command is to RunCode and the code to run is Main().

This function Main() returns to results but sets up a number of checks, variables, and opens the main menu.
 
Erm

I can't seem to get that to work.

Here is what i have.
In a module i have

Public Sub setID()
Public IDLetter As String
IDLetter = "A"
End Sub


In a macro called autoexec i have
Runcode ..... SetID

That is all there is.

I get an error that says invalid outside procedure as it tries to set the IDLetter = "A"
 
Macros can't run Subs - I said Function. :cool:
 
And you wouldn't dimension the Public Variable inside the function.
 
you need to separate the function
Option Compare Database
Option Explicit
Public IDLetter As String




then somewhere else ID="A"
 

Users who are viewing this thread

Back
Top Bottom