Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21100

Run-time error '42': Object required

$
0
0
The Add Form is working fine.

Add Form Code:
  1. Option Explicit
  2. ___________________________________
  3. Private Sub Form_Load()
  4. Me.Top = (Screen.Height - Me.Height) / 2
  5. Me.Left = (Screen.Width - Me.Width) / 2
  6. cboDepartment.Clear
  7. cboDepartment.AddItem "Department 1"
  8. cboDepartment.AddItem "Sample 2"
  9. cboDepartment.AddItem "Sample 3"
  10. cboDepartment.AddItem "Sample 4"
  11. cboDepartment.AddItem "Sample 5"
  12. cboSchool.Clear
  13. cboSchool.AddItem "School 1"
  14. cboSchool.AddItem "School 2"
  15. cboSchool.AddItem "School 3"
  16. cboSchool.AddItem "School 4"
  17. cboSchool.AddItem "School 5"
  18. cboStatus.Clear
  19. cboStatus.AddItem "RECEIVED"
  20. cboStatus.AddItem "PRINTED"
  21. End Sub
  22. ___________________________________
  23. Private Sub txtOwner_LostFocus()
  24. On Error GoTo errorowner
  25. FindRecordset "Select Owner From Finder Where Owner = '" & txtOwner & "';"
  26. If Not FindRs.EOF = True Then
  27. If FindRs.Fields("Owner").Value = txtOwner Then
  28. MsgBox "I.D. Owner already exist. Please specify another one.", vbExclamation, "I.D. Owner"
  29. txtOwner.SetFocus
  30. txtOwner.BackColor = vbYellow
  31. txtOwner.Text = vbNullString
  32. Else
  33. txtOwner.BackColor = vbWhite
  34. End If
  35. Else
  36. txtOwner.BackColor = vbWhite
  37. End If
  38. Exit Sub:
  39. errorowner:
  40. MsgBox Error.Description, vbCritical, "Error"
  41. Set FindCon = Nothing
  42. Set FindRs = Nothing
  43. End
  44. End Sub
  45. ___________________________________
  46. Private Sub cmdSave_Click()
  47. On Error GoTo errorsave
  48. If txtOwner.Text = vbNullString Or cboDepartment.ListIndex = -1 Or cboSchool.ListIndex = -1 Then
  49. MsgBox "Please fill the required fields in order to proceed.", vbExclamation, "Saving Status"
  50. Exit Sub:
  51. End If
  52. executeQuery "INSERT INTO Finder(Owner, Acquired, Released, Department, School, Status)" _
  53. & " VALUES ('" & txtOwner & "', '" & txtAcquired & "', '" & txtReleased & "', '" & cboDepartment & "', '" & cboSchool & "', '" & cboStatus & "');"
  54. Call RefreshListview
  55. If MsgBox("New I.D. has been added now , Do you want to enter another I.D.?", vbYesNo + vbQuestion, "Confirmation") = vbYes Then
  56. Call ClearAll
  57. Else
  58. Unload Me
  59. Call RefreshListview
  60. End If
  61. Exit Sub:
  62. errorsave:
  63. MsgBox Err.Description, vbCritical, "Error"
  64. Set FindCon = Nothing
  65. Set FindRs = Nothing
  66. End
  67. End Sub
  68. ___________________________________
  69. Private Sub ClearAll()
  70. Dim txt, cbo As Control
  71. For Each txt In Me
  72. If TypeOf txt Is TextBox Then
  73. txt.Text = vbNullString
  74. End If
  75. Next txt
  76. For Each cbo In Me
  77. If TypeOf cbo Is ComboBox Then
  78. cbo.ListIndex = -1
  79. End If
  80. Next cbo
  81. End Sub
  82. ___________________________________
  83. Private Sub cboDepartment_Click()
  84. cboDepartment.Enabled = True
  85. End Sub
  86. ___________________________________
  87. Private Sub txtReleased_change()
  88. txtReleased.Enabled = False
  89. End Sub
  90. ___________________________________
  91. Private Sub txtOwner_KeyPress(KeyAscii As Integer)
  92. KeyAscii = Asc(UCase(Chr(KeyAscii)))
  93. End Sub

Viewing all articles
Browse latest Browse all 21100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>