Module ignored on users' machines

W

WiseMonkey

I have a module called (for want of something better..."AutoExec") that sets
up a few Public variables. One of the variables is set up thus:

"Option Compare Database

Option Explicit

Public Const goodPwd = "xxxxxxxxx" "
etc. etc.

I can compare user input at any stage to this password to check if they have
entered a valid password in the following manner:

If txtEntered = goodPwd Then
Do Something
Else
Do Something else
End If


Here is the problem....

When I send the database to my users this part of the code does't seem to
run. What they are telling me is that they enter the correct password into a
text box on a form and click the OK button or whatever and nothing happens.
No message telling them that the password was correct or incorrect. Nothing.

The strange part is that it works perfectly on my computer.

I have checked to see that all the referenced libraries are the same and
that all the security settings are the same. I cannot imagine what can be
causing this.

All users are using Access '07 and the Db was created in '07.

All users are using XP (service pack 2....?)

Any clues?
 
D

Dale Fye

Although AutoExec does not show up as a reserved word in Allen Brownes
reserved and problem word list ( ), I'd try changing the name of the module
to something else. Personally I have a module (mod_Variables) setup where I
instantiate global variables (not used very much) and functions that I treat
as variables.

But where is the code that checks for the "goodPwd". It should be in the
Click event of the password forms Login button.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
W

WiseMonkey

You are correct Dale. The code to check the pwd is in the click event of a
button on a form. The same form appears whenever a user tries to access any
parts of the Db that are protected.

I will take your advice and try changing the name of the module. I am in
Australia and my users are in the U.S.A so there is always a delay before I
get the results.

Thanks for your assistance.

BTW do you know of any good resources for discussion of the concept of using
modules to reduce coding. ie. Set up Global variables, use functions as
variables etc?
 
D

Dale Fye

No particular documentation. You can search the groups for Global
Variables. There are some real downsides (the biggest being that they tend
to loose their values when an unhandled error occurs. The other being that
you cannot use them in queries.

I like to use functions to store variables. The big advantage is that they
rarely loose their values, and they can be used in queries. So if I have a
query that I want to be able to run from a couple of different forms, I can
set the value of the function from any form, then use it in my query. An
example might be:

Public fnID(Optional SomeValue as Variant = Null) as Variant

'I declare SomeValue as a variant because I don't know what value the
user is going to
'pass, if any. I define the default value as NULL, to make it easy to
test

'By using a static variable myID will retain its value from one use of
this function to another.
Static myID as Variant

If isempty(myID) Then myID = Null

If not isnull(SomeValue) then myID = SomeValue
fnID = myID

End Function

Now I can create a report that uses a query that is filtered on fnID(), and
make that report available from any form, without having to display the ID
value on that form. Another way to accomplish this is to open a form during
startup that is hidden, and contains controls for all of the values you want
to use throughout the application. When I use this technique, I will
normally bind this to tbl_Variables in my database, so that all of these
values that are being used throughout the application are actually saved and
persisted from one use of the application to another. In the past, I have
generally put this in a local table, in the front end of the database, but
you could just as easily put it in the backend, and have multiple records,
one for each user, and filter the form on the userid.

HTH
Dale
 
W

WiseMonkey

Most interesting.... Thanks for your input Dale.

Dale Fye said:
No particular documentation. You can search the groups for Global
Variables. There are some real downsides (the biggest being that they tend
to loose their values when an unhandled error occurs. The other being that
you cannot use them in queries.

I like to use functions to store variables. The big advantage is that they
rarely loose their values, and they can be used in queries. So if I have a
query that I want to be able to run from a couple of different forms, I can
set the value of the function from any form, then use it in my query. An
example might be:

Public fnID(Optional SomeValue as Variant = Null) as Variant

'I declare SomeValue as a variant because I don't know what value the
user is going to
'pass, if any. I define the default value as NULL, to make it easy to
test

'By using a static variable myID will retain its value from one use of
this function to another.
Static myID as Variant

If isempty(myID) Then myID = Null

If not isnull(SomeValue) then myID = SomeValue
fnID = myID

End Function

Now I can create a report that uses a query that is filtered on fnID(), and
make that report available from any form, without having to display the ID
value on that form. Another way to accomplish this is to open a form during
startup that is hidden, and contains controls for all of the values you want
to use throughout the application. When I use this technique, I will
normally bind this to tbl_Variables in my database, so that all of these
values that are being used throughout the application are actually saved and
persisted from one use of the application to another. In the past, I have
generally put this in a local table, in the front end of the database, but
you could just as easily put it in the backend, and have multiple records,
one for each user, and filter the form on the userid.

HTH
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top