macro will not run

jtbrown1955

Registered User.
Local time
Today, 01:40
Joined
May 28, 2005
Messages
17
I have a split database that is shared on the network. Three computers have the front end. The back end is on the network. I obtained a module on this forum to bypass the shift key on start up. This is to protect the database from want-a-be hackers. (we have plenty here) This has worked great for about 6 months. I came back from some days off and the macro will not run on one of the computers. I put the database back together and deleted everything, then imported everything back in from a backup I had. I imported everything; forms, tables, reports, the module and the macro. I split the database and redistrubeted the front ends to the other computers. Same thing, runs on 2, won't on the third. I get the following error; "Compile error: Can't find project or library" in the code, the following line is highlighted in yellow; Function faq_DisableShiftKeyBypass() As Boolean and in the following line Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, False) the dbBoolean is highlighted in blue. Here is the code I got off this forum, I wished remembered who to give the credit to, but I don't.

Option Compare Database
Option Explicit

Function faq_DisableShiftKeyBypass() As Boolean
'The next time the database is opened
' after this function has been run,
' the autoexec macro will not be bypassed,
' even if the shift key is pressed.
MsgBox "DisablesShiftKey"
On Error GoTo errDisableShift
Dim db As DAO.Database
Dim prop As DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowByPassKey") = False
faq_DisableShiftKeyBypass = True
exitDisableShift:
Exit Function
errDisableShift:
'The AllowBypassKey property is a user-defined
' property of the database that must be created
' before it can be set. This error code will execute
' the first time this function is run in a database.
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function DisableShiftKeyBypass did not complete successfully."
faq_DisableShiftKeyBypass = False
GoTo exitDisableShift
End If
End Function


Function faq_EnableShiftKeyBypass() As Boolean
MsgBox "EnablesShiftKey"
'The next time the database is opened
' after this function has been run,
' the autoexec macro will not be bypassed,
' even if the shift key is pressed.
On Error GoTo errEnableShift
Dim db As DAO.Database
Dim prop As DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowByPassKey") = True
faq_EnableShiftKeyBypass = False
exitEnableShift:
Exit Function
errEnableShift:
'The AllowBypassKey property is a user-defined
' property of the database that must be created
' before it can be set. This error code will execute
' the first time this function is run in a database.
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, True)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function EnableShiftKeyBypass did not complete successfully."
faq_EnableShiftKeyBypass = False
GoTo exitEnableShift
End If
End Function

Again, this runs on two computers, but not the third. I am running Access 2000.
 
While you have the VBA code page on your screen, click on the menu «Tools» and choose «References». Now see if there is a difference in the list between that PC and the others.
 
Newman said:
While you have the VBA code page on your screen, click on the menu «Tools» and choose «References». Now see if there is a difference in the list between that PC and the others.
Yes, that was it, I guess. On the computer that failed, the acrobat control for active x was missing. I unchecked that box and the macro runs now. I guess I shouldn't look a gift horse in the mouth, but why would acrobat have anything to do with it and how would it have got changed?
 
I am not a specialist in this but the script you are using needs one of the references in that list. but when it tries to read it, it sees that one of them is missing and stops without looking at the others.

One of the reason I see that could explain the fact that this reference is missing is that someone might have upgraded their Acrobat program so they now have a different reference to it.

I must admit that this is highly disturbing, but it often is the cause of problems when something goes wrong only on one computer. So, the first thing to look at when something like this happens, it's references.

Glad that I could help you!
 

Users who are viewing this thread

Back
Top Bottom