Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help on usernames and passwords 1

Status
Not open for further replies.

proggy

Programmer
Apr 21, 2002
46
US
I want ideas on creating an application.
whenever we start access, a dialog box should pop up and ask for username and password.. these should be stored into database...
then a separate set of table for this particular user should be created..
please somebody help me with this...
 
why don't you use access security. then you can give different levels of access to your database. if you are just trying to make a "dummy" login, tell me and I will send you some code that I use with the access security that I have setup.

I didn't understand what you were saying here, "then a separate set of table for this particular user should be created."

CM
 
I have set up security by securty wizard .. but I guess i don't want that..
I want some dummy security which asks for username and password for as many users as i want..( please send me your code that might help me a lot)

ab't the second part..
my boss wants.. this way..
my database takes in few parameters and searches and returns corresponding records..
so.. if user1 searched a material...and then agin searches another material then he wants to retrieve materials unique to this user1..
please give me some idea how to do this..

 
This is the code for a form that I have setup to open when a database is open. As far as the second part, I really don't understand what you are wanting. Sorry.



Private Sub cmdEnter_Click()

Dim db As DATABASE
Dim rs As Recordset
Dim frm As Form, ctl As Control, ctl2 As Control
Dim varResult As Variant
Dim varResult2 As Variant
Dim sLogin As String
Dim sPassword As String

On Error GoTo cmdEnter_Click_Error

Set db = CurrentDb
Set rs = db.OpenRecordset("tblLogin")
Set frm = Forms!frmLogin
Set ctl = frm!txtLogin
Set ctl2 = frm!txtPassword

'This will return "" or Empty if txtLogin is blank
varResult = Nz(ctl.Value)
varResult2 = Nz(ctl2.Value)

'If either field is blank it will start over, if both have values then it will continue
If (varResult = "" Or varResult2 = "") = True Then
MsgBox "You did not fill this form out correctly. Plese fill in all fields....", , "Missing Info"
ctl = ""
ctl2 = ""
ctl.SetFocus
Exit Sub
Else
'Everything looks fine so continue
sLogin = Me!txtLogin.Value
sPassword = Me!txtPassword.Value
End If

rs.MoveFirst

Do Until rs.EOF

If sLogin = rs!txtLogin Then
If sPassword = rs!txtPassword Then
MsgBox "You are now logged in", , "Logged In"
DoCmd.Close acForm, "frmLogin"
DoCmd.OpenForm "frmMain"
Exit Sub
Else
MsgBox "You have the login in correct but you did not supply the correct password. Please try again", , "Wrong Password"
Me!txtPassword.SetFocus
Exit Sub
End If
Else

rs.MoveNext
End If
Loop
MsgBox "This Login name is unrecognized"
rs.Close
Me.txtLogin.SetFocus

cmdEnter_Click_Exit:
Exit Sub

cmdEnter_Click_Error:
'If Err.Number = 94 Then
'Me!txtLogin.SetFocus
'Else
MsgBox Err.Number & ": " & Err.Description
'End If
Resume cmdEnter_Click_Exit

End Sub
 
Thanks man..
Here in the code.. do u already have a table 'tblLogin' with usernames and passwords ??
Can you tell me how did u set that up ??
thanks,
 
To have a user limited to a sub-set of data within a table (I think you are partly looking for this)...

1. Establish your criteria (say office location) that is unique to each user. I recently used a combo box that forwarded to hidden text boxes on a form. Capture this data (from text boxes) in a global variable as a string.
(Assume Table has value - office code)

2. Display your forms based on a query with the value of office code set to the global variable.

Hope this helps. [ponder]
 
I am implementing cainemart's code.. it's working fine..
I will try your suggestion too but I did not understand completely what u r trying to say.. Mr.sathandle...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top