Restricting Data based on Logon XID and Closing App

  • Thread starter Thread starter slr
  • Start date Start date
S

slr

I have filters setup to restrict the data available
to the user based on their logon id. The startup
form requires the entering of their logon, if they are not
on the authorized list of users, the app should close,
however, the following code is not working properly. Any
ideas would be helpful.

If (Eval("Forms!frmLogon!Authorized = ""yes"" ")) Then
Me.Visible = False
DoCmd.OpenForm "Switchboard", acNormal, "", "", ,
acNormal
'DoCmd.Close acForm, frmlogon

Else
MsgBox "You are not authorized for this application",
vbExclamation, ""
DoCmd.Quit
'application.Quit acExit


End If
 
slr said:
I have filters setup to restrict the data available
to the user based on their logon id. The startup
form requires the entering of their logon, if they are not
on the authorized list of users, the app should close,
however, the following code is not working properly. Any
ideas would be helpful.

If (Eval("Forms!frmLogon!Authorized = ""yes"" ")) Then
Me.Visible = False
DoCmd.OpenForm "Switchboard", acNormal, "", "", ,
acNormal
'DoCmd.Close acForm, frmlogon

Else
MsgBox "You are not authorized for this application",
vbExclamation, ""
DoCmd.Quit
'application.Quit acExit
End If


What does "not working properly" mean?

What actually happens?

Does the Authorized text box actuall contain the text string
"Yes"? Or is it a True/False value?

Why are you using Eval? I can't see any reason for it here.
 
As Marshall said, we can't guess what you mean by "it isn't working"! A bit
more detail would be helpful, no?

However, the Eval() statement is clearly not required, and it is probably
not returning the value that you think it should.

The logon form must have some method of knowing whether the entered username
is or isn't correct. You haven;'t told us what that is, so I will take a
guess. Say that it does this by checking to see if there is a record in
table MyTable where the field TheUser is equal to the value in a string
variable strName in the logon form.

This is what the code could look like:

if nz (dlookup (True, "MyTable", "TheUser = """ & strName & """") ,
False) then
' found!
else
' not found!
endif

HTH,
TC
 
Back
Top