Dan:
Here is the short version of one way that I like to use.
Use (or create) a simple log-in form. Bind your tblUsers to the form. Make
sure the form is modal.
After the user enters a userId and password, use a Find or FindFirst method
to look up the userID and then verify that the password entered agrees with
the password in that table. If it does not, use a MsgBox to tell the user
they are not validated. You can add code to allow for more than one attempt
or you can close the form, your call.
If the password entered does agree with the password in the tblUsers, hide
the log-in form, but do not close it (set form Visible = False). You may
need to set the log-in form's Modal property to 'No'.
What you will do will simply look for whether or not the log-in form is
open. Below is a function to do this. Place this code in a General module
for use across multiple forms:
Public Function IsOpen(ByVal strFormName As String) As Boolean
'Returns True if specified form is open in Form view
Const conDesignView = 0
Const conObjStateClosed = 0
IsOpen = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsOpen = True
End If
End If
End Function
Then add some code to the Load Envent on the form with the button you want
to enable. This code would look somethong like this:
If IsOpen("LogIn") Then
cmdMyButton.Enabled = True
Else
cmdMyButton.Enabled = False
End If
There are many other ways to this but this will allow you to call the log-in
form as often as you need it. You can even add a field for security level
in the table and form that allows for various options.
Let me know if this helps.
--
Thanks,
Randy
Dan @BCBS said:
YES to all 3 questions.
Public Sub userCheck()
lCriteria = "SELECT DISTINCTROW tblUsers.* FROM tblUsers "
lCriteria = lCriteria & "WHERE (((tblUsers.RACFID)=" & """" &
cboLogonName & """" & ") "
lCriteria = lCriteria & "AND ((tblUsers.Password)=" & """" & txtPassword
& """" & "));"
Set lrs = ldb.OpenRecordset(lCriteria)
End Sub
/////////////////////////////////////////
:
Dan:
Are you having the user login? Are you using a log-in form? Does it have a
password?
Post back and I will try to help
--
Thanks,
Randy
:
I asked a similar question, but I must try to clearify:
I just want to enable/disable a command button when a form is opened, based
on a true/false from another table. The word Table does not work
"Table.tblUser" (tblUser is my veriable)...
Private Sub Form_Open_Click()
If Table.tblUser = True Then
Command125.Enabled = True
Else
Command125.Enable = False
MsgBox "You do not have permission to change this field."
Cancel = True
Me![DateClosed].Undo
End If
End Sub
//////////////
Please help....