'Text3, Text 4 and Data1 all have Visible
'property's set to False Private Sub Command1_Click() SearchStr$ = Text1.Text 'Search the database For the information Data1.Recordset.Index = "User" 'This is my index Property Data1.Recordset.Seek "=", SearchStr$ If Data1.Recordset.NoMatch = False And Text3.Text = _ Text2.Text Then ' If the text in Text1 = a record and the relation ' password text = correctly then... ' This sequence here is like a access detection.. ' If the User only had access to this form and not that then ' you would add another invisible Text box and ' and grant access or restricted access to the form.. If Text4.Text = 0 Then MsgBox "User Logged On to Unrestricted program" ElseIf Text4.Text = 1 Then MsgBox "User Logged On to Restricted program" Else MsgBox "User Logged On to Default program" End If Else MsgBox "No access you piece of $#%^!" End If End Sub Assumes:If understanding VB code is easy for you don't read two much into the text.. This code uses the the following 4 Text boxes two of which are invisible... set there properties of Visible to = False It uses one Command Button and 1 Data control which property's of Visible is also set to false The security For this code is not complete.. To enhance the security when building a database application you should password the database and or encrypt the text and or put the access file on a restricted drive.. You will need to build a database in Access or in Visual Data Manager (comes With VB) build tables of User Password and Access... In it you will need a Index.. I used the term "User" (if you not sure how to build or work with a database open up northwind.mdb or biblio.mdb) Link data1 to the database you created... Alright now link the datasource of Text3 to data1 Then link datafield as password.. Do the same For Text4 but link it to datafield access.. Insert the code and make any neccessary name changes.. and run.. Try out your User name and password... Did you Get the the proper MsgBox text? Note the password is Case sensetive... You can enhance this code For distinct User access by User Type With the Access number.. Other things I've done is add a Hello name to the database and have it display when the user logs on correctly.. something like "Hi Mathew, Welcome" corny yes but sort of cool.. I'd also recommened adding a Adminstrator control form.. where you can easily change User name's, add User names, delete... ect. ect. Of course a Adminstrator would have to have a specific Access number for that special form.. This code isn't perfect.. it can be better but.. It's a great way to Do a user/password database With unlimited users and unlimited ways to restrict access.. not to mention a great way to change all the information.. Shortly I will put together a downloadable demo.. Side Effects: There's that damn annoying.. VB messege.. No current record found.. |