Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Public dbcon As New ADODB.Connection
Public rs As New ADODB.Recordset
Public fsy As New Scripting.FileSystemObject
Public id As String
Public priv As String

Private Sub Form_Load()

Set dbcon = Nothing
    dbcon.CursorLocation = adUseClient
    dbcon.Open "Provider=Microsoft.Jet.oledb.4.0;data source = " & App.Path & "\database\dbuser.mdb;"
    Set rs = Nothing
    
End Sub

Private Sub login_Click()

If Text1.Text = "" Or Text2.Text = "" Then

MsgBox "Fillup the the field before procceding!"
Exit Sub
End If

Set rs = Nothing
rs.Open "select * from tblemployee where [UserName]= '" & Text1.Text & "' and [Password]='" & Text2.Text & "'", dbcon, , adLockReadOnly

If rs.RecordCount > 0 Then
'MsgBox "Welcome" "" & rs.Fields("FirstName")
id = rs.Fields("FirstName")
priv = rs.Fields("Position")
   If priv = "Admin" Then
   Acountofemployee.File.Enabled = True
   Agri.Command1.Enabled = True
   Agriincoming.File.Enabled = True
  
   
  ElseIf priv = "Kagawad1" Then
   
Cash.Command4.Enabled = False
Cash.Command5.Enabled = False
Cash.Command3.Enabled = False
Cash.Command2.Enabled = False
Cash.Command7.Enabled = False

Events.Save.Enabled = False
Events.up.Enabled = False
Events.can.Enabled = False
Events.edit.Enabled = False
Events.del.Enabled = False
Events.Add.Enabled = False

   
  ElseIf priv = "Secretary" Then
  Acountofemployee.File.Enabled = True
   Agri.Command1.Enabled = True
   Agriincoming.File.Enabled = True
   Agrilatest.File.Enabled = True
   Agrilatest.Command1.Enabled = True
   BO.File = True
   CP.File.Enabled = True
   CP.Command1.Enabled = True
  

   
   ElseIf priv = "Kagawad2" Then
   Agri.Command1.Enabled = False
   incominginfrast.File.Enabled = True
   Infrastructure.File.Enabled = True
   Infrastructure.Command1.Enabled = True
   Cash.Command6.Enabled = False

   
   ElseIf priv = "Treasurer" Then
   Acountofemployee.File.Enabled = False
   Agri.Command1.Enabled = False
   Agriincoming.File.Enabled = False
   Agrilatest.File.Enabled = False
   Agrilatest.Command1.Enabled = False
   BO.File = False
  
   Else
   Acountofemployee.File.Enabled = False
   Agri.Command1.Enabled = False
   Agriincoming.File.Enabled = False
   Agrilatest.File.Enabled = False
   Agrilatest.Command1.Enabled = False
   BO.File = False

   End If
    
    
Menu.Show
Unload Me
    
Else

MsgBox "Invalid User name and password !"

End If

End Sub
Posted
Updated 27-Sep-14 23:57pm
v2
Comments
Richard MacCutchan 28-Sep-14 4:15am    
No idea, you need to explain what your problem is.
Member 11096118 28-Sep-14 5:29am    
i want a code that some of the user cannot access or edit the other form
i try that code in vb.net but errors
Richard MacCutchan 28-Sep-14 7:10am    
Well I am afraid that we cannot guess what thos errors may be.
[no name] 28-Sep-14 5:19am    
VB6 <> VB.NET. It's called a "rewrite".
Tino Fourie 28-Sep-14 18:59pm    
Prior to a "rewrite", download Visual Studio Express 2005 / 2008 and try an Import of your VB6 project. Chances are great that it will NOT be able to import is because VB6 uses .OCX controls which is unknown to .Net. I just tried it myself on a very small VB6 project and VS2008 failed to import it.

EDIT:
I don't think you should have too much trouble rewriting the above code into VB.Net. I am not familiar with ADO (ODBC I am more familiar with) but from what I have seen here on CP there is not much difference from the code you used in VB6. The only code that is not familiar to me is the "Cash." and "Events." code in your example. Take some time and look at the "WithEvents" code in VB.Net.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900