Help with If Then Else statement

cooh23

Registered User.
Local time
Today, 08:50
Joined
Dec 5, 2007
Messages
169
Good Evening Everyone,

I am having a problem getting this code below to work

Code:
Private Sub btnAdminTools_Click()
On Error GoTo Err_btnAdminTools_Click

If admin = True _
Then
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmallinonereport"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
    MsgBox "You Do Not Have access to this Form"
Exit_btnAdminTools_Click:
    Exit Sub

Err_btnAdminTools_Click:
    MsgBox Err.Description
    Resume Exit_btnAdminTools_Click
End If

End Sub

Basically, what i am trying to do is when a user who is not classified as an admin should get the error "You do not have access to this form", if they are admin, then they can open it.

Thank you,
 
Code:
Private Sub btnAdminTools_Click()
On Error GoTo Err_btnAdminTools_Click 

If admin = True _ [color=red][b]<--- What is this referring to?  A check box?[/color][/b]
So, you are trying to check a boolean type control? Is that what's hanging you up on this?
 
So, you are trying to check a boolean type control? Is that what's hanging you up on this?

Hi. Thank you for looking at this. I got it to work now. But here's what i am doing.

I have a module that looks into a table to see if my username (my windows login called by environ("username")) is an admin under Roles in the table). If not, then to give me an error box. I actually didn't change anything in the code I provided. I just had to compile the code and compact the database. For whatever reason, it worked.

Thank you
 

Users who are viewing this thread

Back
Top Bottom