423,335 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,335 IT Pros & Developers. It's quick & easy.

i have a problem with the cmdNavBar error alway appearing Operation is Not allowed wh

P: 1
I have a problem with the cmdNavBar error alway appearing Operation is Not allowed:
Expand|Select|Wrap|Line Numbers
  1. <FORM>
  2. Private Sub cbodept_Click()
  3.     If cbodept.Text = "Faculty" Then
  4.         txtgross.Text = "10000"
  5.     Else
  6.     If cbodept.Text = "Accounting" Then
  7.         txtgross.Text = "20000"
  8.     Else
  9.     If cbodept.Text = "Registrar" Then
  10.         txtgross.Text = "15000"
  11.     Else
  12.     If cbodept.Text = "Technical Support" Then
  13.         txtgross.Text = "12000"
  14.     Else
  15.     If cbodept.Text = "Marketing" Then
  16.         txtgross.Text = "18000"
  17.     Else
  18.     If cbodept.Text = "Administrative" Then
  19.         txtgross.Text = "25000"
  20.  
  21.     End If
  22.     End If
  23.     End If
  24.     End If
  25.     End If
  26.     End If
  27.  
  28. End Sub
  29.  
  30. Private Sub cmdaction_Click(Index As Integer)
  31.  
  32.     Select Case Index
  33.  
  34.         Case 0 ' Record
  35.  
  36.             rs.Open "Select * from tblpayroll", cn, 3, 3
  37.             rs.AddNew
  38.             rs!PayrollDate = DTPicker1.Value
  39.             rs!EmployeeNo = txtempno.Text
  40.             rs!EmployeeName = txtempname.Text
  41.             rs!Department = cbodept.Text
  42.             rs!GrossPay = txtgross.Text
  43.             rs!Deduction = txtdeduc.Text
  44.             rs!Net = txtnet.Text
  45.             rs.Update
  46.             MsgBox "New Payroll has been Added!"
  47.  
  48.             Set rs = Nothing
  49.  
  50.         Case 1 ' Delete Record
  51.  
  52.             Dim res As VbMsgBoxResult
  53.             On Error GoTo fixdel
  54.             res = MsgBox("Delete" & txtempname & "information?", vbYesNo + vbQuestion, "confirm")
  55.  
  56.             If res = vbYes Then
  57.                 rs.Open "Select * from tblpayroll where EmployeeNo ='" & txtempno.Text & "'", cn, 3, 3
  58.                 rs.Delete
  59.                 rs.Update
  60.                 rs.Close
  61.                 Set rs = Nothing
  62.             End If
  63.  
  64. fixdel:
  65.  
  66.  
  67.             If Err.Number = 6160 Then
  68.                 MsgBox "No data to delete!", vbOKOnly + vbInformation, "Message"
  69.             End If
  70.  
  71.         Case 2 ' Update record
  72.  
  73.  
  74.             rs.Open "Select * from tblpayroll", cn, 3, 3
  75.             rs!PayrollDate = DTPicker1.Value
  76.             rs!EmployeeNo = txtempno.Text
  77.             rs!EmployeeName = txtempname.Text
  78.             rs!Department = cbodept.Text
  79.             rs!GrossPay = txtgross.Text
  80.             rs!Deduction = txtdeduc.Text
  81.             rs!Net = txtnet.Text
  82.             rs.Update
  83.             MsgBox "Current Payroll has been updated!"
  84.  
  85.             Set rs = Nothing
  86.  
  87.         Case 3 'Search record
  88.  
  89.             FindEmployeeNo = InputBox("Enter Employee Number")
  90.             rs.Open "Select * from tblpayroll where EmployeeNo = '" & txtempno.Text & "'", cn, 3, 3
  91.  
  92.             If rs.EOF Then
  93.                 MsgBox "No Such Record!", vbCritical + vbOKOnly, " Error Search"
  94.             End If
  95.  
  96.         Case 4 ' print
  97.             Set rs = Nothing
  98.  
  99.  
  100.             rs.Open "Select * From tblpayroll", cn, 3, 3
  101.  
  102.  
  103.  
  104.             Set DataReport1.DataSource = rs
  105.  
  106.             DataReport1.Show
  107.  
  108.         Case 5 'exit
  109.  
  110.             End
  111.  
  112.     End Select
  113.  
  114. End Sub
  115.  
  116. Private Sub cmdnavbar_Click(Index As Integer)
  117.  
  118.  
  119.  
  120.    rs.Open "Select * from tblpayroll", cn, 3, 3
  121.  
  122.         Select Case Index
  123.  
  124.             Case 0 'movefirst
  125.                 On Error Resume Next
  126.  
  127.  
  128.                 rs.MoveFirst
  129.                 DTPicker1.Value = rs!PayrollDate
  130.                 txtempno.Text = rs!EmployeeNo
  131.                 txtempname.Text = rs!EmployeeName
  132.                 cbodept.Text = rs!Department
  133.                 txtgross.Text = rs!GrossPay
  134.                 txtdeduc.Text = rs!Deduction
  135.                 txtnet.Text = rs!Net
  136.                 If rs.EOF Then
  137.                      MsgBox "First record!"
  138.                 End If
  139.             Case 1 'Move previous
  140.                 On Error Resume Next
  141.  
  142.                 rs.MovePrevious
  143.                 DTPicker1.Value = rs!PayrollDate
  144.                 txtempno.Text = rs!EmployeeNo
  145.                 txtempname.Text = rs!EmployeeName
  146.                 cbodept.Text = rs!Department
  147.                 txtgross.Text = rs!GrossPay
  148.                 txtdeduc.Text = rs!Deduction
  149.                 txtnet.Text = rs!Net
  150.  
  151.                 If rs.EOF Then
  152.                      MsgBox "First record!"
  153.                 End If
  154.  
  155.             Case 2 ' MoveNext
  156.                 On Error Resume Next
  157.  
  158.                 rs.MoveNext
  159.                 DTPicker1.Value = rs!PayrollDate
  160.                 txtempno.Text = rs!EmployeeNo
  161.                 txtempname.Text = rs!EmployeeName
  162.                 cbodept.Text = rs!Department
  163.                 txtgross.Text = rs!GrossPay
  164.                 txtdeduc.Text = rs!Deduction
  165.                 txtnet.Text = rs!Net
  166.  
  167.                 If rs.EOF Then
  168.                      MsgBox "Last record!"
  169.                 End If
  170.             Case 3 'Move last
  171.                 On Error Resume Next
  172.  
  173.                 rs.MoveLast
  174.  
  175.                 DTPicker1.Value = rs!PayrollDate
  176.                 txtempno.Text = rs!EmployeeNo
  177.                 txtempname.Text = rs!EmployeeName
  178.                 cbodept.Text = rs!Department
  179.                 txtgross.Text = rs!GrossPay
  180.                 txtdeduc.Text = rs!Deduction
  181.                 txtnet.Text = rs!Net
  182.  
  183.                 If rs.EOF Then
  184.                      MsgBox "Last record!"
  185.                 End If
  186.         End Select
  187.  
  188.             rs.Close
  189.  
  190. End Sub
  191.  
  192.  
  193. Private Sub Form_Load()
  194. cn.Open "Provider =Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\db1.mdb"
  195.  
  196.  
  197. End Sub
  198.  
  199. Private Sub txtdeduc_Change()
  200. txtnet.Text = Val(txtgross.Text) - Val(txtdeduc.Text)
  201. End Sub
  202.  
  203. Private Sub txtgross_Change()
  204. txtnet.Text = Val(txtgross.Text) - Val(txtdeduc.Text)
  205. End Sub
  206.  
  207. <MODULE>
  208.  
  209. Public cn As New ADODB.Connection
  210. Public rs As New ADODB.Recordset
  211.  
  212. Sub connect()
  213.   Set cn = New ADODB.Connection
  214.   cn.Open "Provider=Microsoft.Jet.OLED.4.0;Data Source=" & App.Path & "\db1.mdb"
  215.   Set rs = New ADODB.Recordset
  216.   rs.ActiveConnection = cn
  217.   rs.CursorLocation = adUseClient
  218.   rs.CursorType = adOpenDynamic
  219.   rs.LockType = adLockBatchOptimistic
  220.  rs.Open "Select * from tblpayroll", cn, 3, 3
  221.   rs.Open
  222.  
  223. End Sub
  224.  
  225.  
tnx in advance. please help me i need to pass this project for my school project..
Mar 9 '18 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
Please repost the error message and tell us what line the problem is happening on so that we can help you.
Mar 12 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.