How Can i run a module in access

  • Thread starter Thread starter Ross.Jezzard
  • Start date Start date
R

Ross.Jezzard

Hi,

I am trying to run a module that i have created in access to prevent
people entering certain sections of the database. I have constructed a
password request when a button is pressed to prevent people being able
to access an admin toolbar with all the master controls.
However whenever i try and run this module i have a error message
advising me that it cannot find the function name i have selected. The
code is as follows;

Public Function Toolbar()

'Attached to On Click event of Administration

Dim strPasswd

strPasswd = InputBox("Enter Password", "Restricted Form")

'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit.

If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Function
End If

'If correct password is entered open Adminsitration Toolbar
'If incorrect password entered give message and exit
If strPasswd = "Pa55word" Then
DoCmd.ShowToolbar "Administration", acToolbarYes
Else
MsgBox "Sorry, you do not have access to this Toolbar",
vbOKOnly, "Important Information"
Exit Function
End If
End Function

Have i missed something from the code? Please help as this is begining
to frustrate me as i just cant see what is wrong. It does work when you
run it in VB but i just cant get it to run in access.

Best Regards

Ross
 
your name of the function is Toolbar ??

(not sure I would use that to avoid a conflict with some internal/intrinsic
namings within Access - - although I don't think that is your problem here..)

in general your Module name and the Public Function name need to be
different and you call the Public Function name....
 
Back
Top