Perhaps this isn't the most appropriate method of verifying user identity, as someone could use an existing login on some
server, or login with someone elses password, but I believe that shouldn't be an issue to deal with here. I've spent the past
8 hours poring over the boards, and can't quite find this particular scenario on the boards. It seems that either a Dcount,
or a DLookup would be the most likely avenues to take, but I am unable to get an accurate result from my If Statements.
I've got my DB to query a current users login to the system, and would like to make some buttons visible for all users,
and some buttons useable to just a specified list of users. If I hard-code the users names into the VBA codes for each action
I am successful, but when I attempt to compare the textbox on the form to a table of allowable users I get a result that
seems to be completely ignoring my if statement and showing everything to everyone. This is the function that is causing the
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Exit_Form_Open_Click
.OpenQuery "qry Mar Geology Data"
.OpenQuery "qry Apr Geology Data"
.OpenQuery "qry Graphing Query"
'These are update queries that I am currently running because my data
'relies on some Excel sheets from another department that I import for
If DLookup("[Allowed Usernames]", "tbl Database Admins", "[Allowed Usernames] = " & [UserNameControl]) Then
' I have also tried various punctuation options based on examples on the
'boards. The [Allowed Usernames] is the field with usernames in the table
'called "tbl Database Admins", and [UserNameControl] is the textbox on
'this form, which is generated via a module that queries the windows
'username, in my case that is which matches an entry in tbl
Me.Modify_Budget.Visible = True
Me.Modify_Forecast.Visible = True
Me.Modify_Calculation_Factors.Visible = True
Me.Daily_Data_Entry.Visible = True
Me.Email_Report.Visible = True
Me.Email_Report_Text.Visible = True
Me.Modify_Email_List.Visible = True
Me.Database_Admin_List.Visible = True
Me.Modify_Budget.Visible = False
Me.Modify_Forecast.Visible = False
Me.Modify_Calculation_Factors.Visible = False
Me.Daily_Data_Entry.Visible = False
Me.Email_Report.Visible = False
Me.Email_Report_Text.Visible = False
Me.Modify_Email_List.Visible = False
Me.Database_Admin_List.Visible = False
I have attempted some error trapping within both if options, but the msgbox's that I put in did not appear at any
point. It seems as if the condition of the if statement is as far as it goes, and the form will open with all options visible
no matter who logs in, whether they are in the database admin list or not.