AutoExec help

Weresmytriple

Registered User.
Local time
Today, 23:17
Joined
Sep 5, 2013
Messages
58
hi all

i am trying to run the code found on http://www.access-programmers.co.uk/forums/showthread.php?t=205223&page=2

the code is
Code:
Option Compare Database
Public Function RunAtStart()
'    KillIt
    DetermineByPass
 
End Function
 
Public Function KillIt() As Integer
 
    If SysCmd(SYSCMD_RUNTIME) = 0 Then
        MsgBox ("This Application cannot be opened directly with Microsoft Access," & vbCrLf & _
        "and can ONLY be opened with the desktop shortcut." & vbCrLf & vbCrLf & _
        "Please double click the shortcut on your desktop to open This Application." & vbCrLf & vbCrLf & _
        "This application will now close."), vbOKOnly, "My Application Name"
        Application.Quit
    End If
End Function
 
Public Function DetermineByPass()
    If Len(Dir(CurrentProject.Path & "\LetMeIn.txt")) = 0 Then
        SetStartupProperties (False)
    Else
        SetStartupProperties (True)
    End If
End Function
 
Public Sub SetStartupProperties(bolParameter As Boolean)
 
    ChangeProperty "StartupShowDBWindow", dbBoolean, bolParameter
    ChangeProperty "AllowBreakIntoCode", dbBoolean, bolParameter
    ChangeProperty "AllowSpecialKeys", dbBoolean, bolParameter
    ChangeProperty "AllowBypassKey", dbBoolean, bolParameter
    ChangeProperty "StartupShowStatusBar", dbBoolean, bolParameter
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, bolParameter
    ChangeProperty "AllowFullMenus", dbBoolean, bolParameter
    ChangeProperty "AllowShortcutMenus", dbBoolean, bolParameter
 
End Sub
 
Public Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270
 
    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True
 
Change_Bye:
    Exit Function
 
Change_Err:
    If Err = conPropNotFoundError Then  ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
        varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function

i have never used the autoexec marco to run code so im not quite sure if im doing this correct but i created a module and saved it as RunAtStart. then i created a macro with the argument "RunCode Fuction Name: RunAtStart" However when i run the macro i get the error message in teh attachments.

Any help on where i am going wrong or how to fix this error will be much appreciated.

thanks

michael
 

Attachments

  • Error Message.jpg
    Error Message.jpg
    37.2 KB · Views: 237
You cant have modules and functions that are called the same, which is why we all addopt and adhere to a naming convention where we pre-fix all the names by its class/type.
Like
tbl Table
qry Query
frm Forms
rpt Report
mcr Macro
mdl Module

This way you are sure you never "pickup" the wrong object by mistake.
 

Users who are viewing this thread

Back
Top Bottom