Error 3075

Juniour

New member
Local time
Today, 12:12
Joined
Mar 3, 2020
Messages
23
Hi

I am stuck with Error 3075.
Code is as folow :

Public Function UserAccess(FormName As String) As Boolean
UserAccess = Nz(DLookup("HasAcess", "tbl_EmployeetypeAccess", "UserSecurity_ID=" & TempVars("EmployeeType") & " AND FormName='" & FormName & "'") = False)
End Function

Any help would be nice..Please?
1583334537859.png
 
Look at the error message. Clearly it shows that tempvars is returning null.
 
Hi. I agree. How are you setting the TempVar value? Also, if the user "has access" to the form, you want this function to return False?
 
Hi

Thanks a million. I have managed to sort the location of the tempVar. That help a lot.
I am a novice to this.

So my tempvar looks like this:
Dim TempUserLogin As TempVars
TempVars!EmployeeType = Me.User_Login.Value

Itis suppose to pick up the numeric value that corrosponds to the user login.
But It sticks to the Name of the user.
Am I missing a code?

To answer your question about the False: I am using a macro that denies access if the module is not met. That is loaded on all the forms.
 
That should be

Code:
TempVars!EmployeeType = me.UserSecurity_ID

If the control is not on your form, add it and bind to the table field
 
That should be

Code:
TempVars!EmployeeType = me.UserSecurity_ID

If the control is not on your form, add it and bind to the table field

Thanks for the feedback,
Could you give me an aexample to set the control on the form and how to bind it to the table field?
 
what is User_Login, a combobox, listbox?
 
It is a Text box, I am sure it wont make a difference if we make it listbox or combo box.
My login coding looks as follows:

Private Sub Ok_Click()

If IsNull(Me.User_Login) Then
MsgBox "Please enter User Login", vbInformation, "UserLogin Required"
Me.User_Login.SetFocus
ElseIf IsNull(Me.Password) Then
MsgBox "Please enter Password", vbInformation, "Password Required"
Me.Password.SetFocus
Else
'Process the job
If (IsNull(DLookup("User_Login", "tbl_Personel", "User_Login ='" & Me.User_Login.Value & "'"))) Or _
(IsNull(DLookup("Password", "tbl_Personel", "Password ='" & Me.Password.Value & "'"))) Then
MsgBox "Incorrect Login ID or Password"
Else

If IsNull(DLookup("[Employed]", "tbl_Personel", "[Employed] = 0")) Then
'MsgBox "LoginID and Password correct"
DoCmd.OpenForm "frm_Switchboard"

ElseIf (DLookup("[Employed]", "tbl_Personel", "[Employed] = -1")) Then
Beep
MsgBox "You Don't Have Access!", vbOKOnly, "Access Denied"


End If
End If
End If
 
Code:
Private Sub Ok_Click()

If IsNull(Me.User_Login) Then
    MsgBox "Please enter User Login", vbInformation, "UserLogin Required"
    Me.User_Login.SetFocus
    Exit Sub
ElseIf IsNull(Me.Password) Then
    MsgBox "Please enter Password", vbInformation, "Password Required"
    Me.Password.SetFocus
    Exit Sub
End If
'Process the job
'User_Login and Password should be on one line

Dim bolEmployed As Variant
Dim rs As DAO.Recordset

Set rs = Currentdb.OpenRecordset("SELECT * FROM tbl_Personel WHERE User_Login = '" & [User_Login] & "' And Password = '" & [Password] & "'", _
    dbOpenSnapShot)

If (rs.BOF And rs.EOF) Then
    Set rs = Nothing
    MsgBox "Incorrect Login ID or Password"
    Exit Sub
End If
bolEmployed = rs!Employed
If IsNull(Tempvars("EmployeeType")) Then
    Tempvars.Add "EmployeeType", rs!EmployeeType
End If
Tempvars!EmployeeType = rs!EmployeeType
Set rs = Nothing

If bolEmployed = False Then
    Beep
    MsgBox "You Don't Have Access!", vbOKOnly, "Access Denied"
Else
    DoCmd.OpenForm "frm_Switchboard"
End If

End Sub
 
Good day,
Thanks for the help. It seems like i am missing something stupid.
Can I send someone my database to assist in solving my issue, I think it will be easier than trying to explain where I am getting stuck.
 
Hi

Thanks a million. I have managed to sort the location of the tempVar. That help a lot.
I am a novice to this.

So my tempvar looks like this:
Dim TempUserLogin As TempVars
TempVars!EmployeeType = Me.User_Login.Value

Itis suppose to pick up the numeric value that corrosponds to the user login.
But It sticks to the Name of the user.
Am I missing a code?
The reason it is setting it to the name is because the Me.User_Login.Value text box contains the user name. You will need to use a combo box in order for this code to work. Or, changes to the code are needed.

Instead, try referring to

SQL:
Forms!frm_Loginform.Recordset("name of primary key field")

If you have set the login form's record source to the User's table.
 
Juniour, re #10, zip your db and send a message to this thread with the zip file attached.
 
Thanks, See https://www.dropbox.com/transfer/AAAAAHON7PK5Z98yJau39oiBxcGdRkzh8QeEIZBiq8JVTun-zv8K2Mw

In short - I am struggeling with user authorisation to access certain forms. Codes are loaded on the Login button and ADD AIRCRAFT button/FORM.
Its a basic system, I am new to this and trying to build it from scratch. Any improvements and suggestions are welcome.

Seems like the database keeps on being to big even after I splitted it and then zip it
 
Some might have a dropbox account. I don't
 
So Sorry,
I have tried to Split the database. Back end is fine but Front end is still to large.
Any suggestion how I can send it to you?
 
How large is the file if zipped? Maybe you can compress first.
 
Thanks, I will test it. You guys are awesome. Thanks for the help so far.
The data base is 3.03mb when zipped
 

Users who are viewing this thread

Back
Top Bottom