Complile Error - Only certain users

G

Guest

Below is code from my database that was working and is not working any
longer. Some of the users are getting compile errors when they open the
database. Can someone please take a look and tell me why this might be
happening? I would greatly appreciate it.

Thanks,

Arlene


Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 
G

Guest

Hi Swedbera,

Your code compiles fine and works on my PC. I suspect that users who are
having a problem have a reference marked a MISSING, whereas those users for
whom the code works do not have a missing reference. A missing reference can
cause problems with common VBA functions, including String$ and Left$, both
of which are used in your procedure.

Open the database on a PC that is presenting the problem. Hit ALT F11 to
open the Visual Basic Editor. Click on Tools > References. Are any of the
references marked as "MISSING"? If so, you must correct this. Here is more
information on missing references:

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

You didn't mention whether or not your database is split into a front-end
(FE) and back-end (BE) files, with only the BE file being shared. Each user
should have their own copy of the FE installed on their local hard drive. You
can easily run into missing reference problems if you attempt to share the
entire database.

If my answer has helped you, please answer yes to the question that reads
"Did this post answer the question?" at the bottom of the message thread.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Below is code from my database that was working and is not working any
longer. Some of the users are getting compile errors when they open the
database. Can someone please take a look and tell me why this might be
happening? I would greatly appreciate it.

Thanks,

Arlene


Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 
G

Guest

Hi Tom,

Thanks for your help. My database is still under development and has not
been split into a FE/BE yet. I did not see any references listed as
'missing', although they were not all there. I had saved a screen shot of
them when I originally added the references and went back to compare with the
references I currently have. I also went to the links that you provided and
found some additional help there. I have gotten everything working now, but
since I have started reading about references (early and late binding), I am
sure that I will have problems again in the future unless I make changes to
my code and remove references that could change and cause my code to stop
working. I don't fully understand all of this, but will do more research. I
do think I know what caused this to happen (this time). I have implemented
security on this database, and when I had problems with it last week, I
created a blank database and moved everything over to the new database,
reapplying security permissions. I read one article that states that this
can cause a problem with references and followed the instructions in the
article to correct it. Fortunately, it corrected the problem quickly.

Could you please answer one more question for me? What is the benefit of
splitting the database into a FE/BE and how does this affect the security
that is implemented on the database?

I appreciate your help with this.

Thanks much!

Arlene
 
G

Guest

Hi Arlene,
Could you please answer one more question for me? What is the benefit
of splitting the database into a FE/BE....

There are several benefits of splitting a database. The most important one
is that sharing an entire database over the network has been identified by
Microsoft personnel as the number one cause of corruption for Access
databases.

A copy of the front-end (FE) database should be placed on each user's local
hard drive. This way, you are helping to minimize network traffic by not
transferring all the bytes of information down the wire that define each
query, form, report, etc. Having a split database allows you, as the
developer, to continue making changes to your copy of the FE database without
the need to gain exclusive control (ie. kick everyone else out) of the
database.
...and how does this affect the security that is implemented on the database?

I'm the wrong person to ask any questions about Access security. I don't use
it myself, because it is not secure at all. There are free tools available on
the internet, if you know the right places to look, that can reveal all
usernames and passwords in a matter of seconds, if the workgroup information
file (.mdw file) is available. Since Access security can be rather confusing,
and difficult to implement, I just don't see the point given that, at best,
it will only keep honest people out. I think it is much better to rely on
Windows security, giving only those user's who have a need the proper access
rights to the shared folder for the back-end (BE) database.


Tom
____________________________________________

:

Hi Tom,

Thanks for your help. My database is still under development and has not
been split into a FE/BE yet. I did not see any references listed as
'missing', although they were not all there. I had saved a screen shot of
them when I originally added the references and went back to compare with the
references I currently have. I also went to the links that you provided and
found some additional help there. I have gotten everything working now, but
since I have started reading about references (early and late binding), I am
sure that I will have problems again in the future unless I make changes to
my code and remove references that could change and cause my code to stop
working. I don't fully understand all of this, but will do more research. I
do think I know what caused this to happen (this time). I have implemented
security on this database, and when I had problems with it last week, I
created a blank database and moved everything over to the new database,
reapplying security permissions. I read one article that states that this
can cause a problem with references and followed the instructions in the
article to correct it. Fortunately, it corrected the problem quickly.

Could you please answer one more question for me? What is the benefit of
splitting the database into a FE/BE and how does this affect the security
that is implemented on the database?

I appreciate your help with this.

Thanks much!

Arlene
____________________________________________

:

Hi Swedbera,

Your code compiles fine and works on my PC. I suspect that users who are
having a problem have a reference marked a MISSING, whereas those users for
whom the code works do not have a missing reference. A missing reference can
cause problems with common VBA functions, including String$ and Left$, both
of which are used in your procedure.

Open the database on a PC that is presenting the problem. Hit ALT F11 to
open the Visual Basic Editor. Click on Tools > References. Are any of the
references marked as "MISSING"? If so, you must correct this. Here is more
information on missing references:

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

You didn't mention whether or not your database is split into a front-end
(FE) and back-end (BE) files, with only the BE file being shared. Each user
should have their own copy of the FE installed on their local hard drive. You
can easily run into missing reference problems if you attempt to share the
entire database.

If my answer has helped you, please answer yes to the question that reads
"Did this post answer the question?" at the bottom of the message thread.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Below is code from my database that was working and is not working any
longer. Some of the users are getting compile errors when they open the
database. Can someone please take a look and tell me why this might be
happening? I would greatly appreciate it.

Thanks,

Arlene


Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 

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