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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limited Access to Certain Buttons

Status
Not open for further replies.

jsaliers

Programmer
Jan 23, 2003
129
US
I have done this before in a different database, and it works fine. However, when I set it up in a second database, I am getting errors. Here is the code in the On Load event for the form:

'**Begin Code**
Private Sub Form_Load()

'find out if the user has access
Dim chkUser As Recordset
Dim lpBuff As String * 25
Dim ret As Long, UserName As String

'Get the user name minus any trailing spaces found in the name.
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

'set if there is a user
Set chkUser = CurrentDb.OpenRecordset("Select * FROM Security WHERE Name = '" & UserName & "'")

If chkUser.RecordCount = 1 Then
Check53.Locked = False
Check43.Locked = False
Else
Check53.Locked = True
Check43.Locked = True
End If

End Sub

'**End Code**

I also included the following lines of code in the general declarations:

'**Begin Code**

Option Compare Database
Option Explicit
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

'**End Code**

When the form is opened, I get a compile error that highlights the 'Chr' function and says something to the effect of "Project or Library not found.' Any ideas are greatly appreciated. As I stated earlier, I took the code from a different database that works correctly, so I don't understand why this one is not working.

Thanks,

Jon
 
You are the proud owner of a corrupted or conflicting VBA library. This can happen when the conversion wizard has an error when you convert a database, or when you have two different versions of the VBA library on your machine (like two verions of Access), or if the library file location is changed.
The VBA library is usually found on the C:Drive, somewhere like this
C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL

Check the references for the error-generating db. You may find a MISSING note by the Visual Basic for Applications listing, or you may have to look at the path for your working db, and re-browse the non-working db reference.
If all else fails, create a new db from scratch and import all your tables, queries, forms, and reports to the new db.
 
Unfortunately, you are correct (at least partially). I checked the reference list, and found a listing with MISSING next to it, but not the VBA listing. Instead, it was the following:

MISSING: vidtc3

path = C:\Program Files\Microsoft Visual Studio\VIntDev98\bin\VIDTC

This database was previously converted by our Network Admin to post on the network, but I have no idea what he did or how he did it. How do I go about fixing this problem?

Thanks in advance!

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top