Advertisement
ReidYanz

Sorry mga Sir Nagkarambol-rambol na ang error ko :(

Sep 21st, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.80 KB | None | 0 0
  1. Sorry Sir Nagkarambol-rambol na ang error ko :(
  2.  
  3.  
  4.  
  5.  
  6. Form1
  7.  
  8. Private Sub login()
  9. Module3.getconnected
  10. Dim rs As New ADODB.Recordset
  11. rs.Open "Select * From tblUser where username= '" & Text1 & "'", con, adOpenStatic, adLockReadOnly
  12. If rs.RecordCount < 1 Then
  13. MsgBox "Username is invalid", vbInformation, "Login"
  14. Text1.SetFocus
  15. Exit Sub
  16. Else
  17. If Text2.Text = rs!Password Then
  18. Unload Me
  19. Load Form2
  20. Form2.Show
  21. Exit Sub
  22. Else
  23. MsgBox "Password is invalid", vbInformation, "Login"
  24. Text2.SetFocus
  25. Exit Sub
  26. End If
  27. End If
  28. Set rs = Nothing
  29.  
  30.  
  31. End Sub
  32.  
  33. Private Sub Command1_Click()
  34. If Text1.Text = "" Then
  35. MsgBox "Username is Empty"
  36. Text1.SetFocus
  37. Exit Sub
  38. ElseIf Text2.Text = "" Then
  39. MsgBox "password is Empty"
  40. Text2.SetFocus
  41. Exit Sub
  42. Else
  43. Call login
  44. End If
  45.  
  46.  
  47. End Sub
  48.  
  49.  
  50. Private Sub Command2_Click()
  51. Form1.Hide
  52. Form3.Show
  53. End Sub
  54.  
  55. Private Sub Form_Load()
  56. Text2.PasswordChar = "*"
  57. End Sub
  58.  
  59.  
  60.  
  61. Private Sub Text1_KeyPress(KeyAscii As Integer)
  62. If KeyAscii = 13 Then
  63. Text2.SetFocus
  64. End If
  65. End Sub
  66.  
  67. Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
  68. If KeyCode = vbKeyReturn Then
  69. KeyCode = 0
  70. Call Command1_Click
  71. End If
  72.  
  73. End Sub
  74.  
  75.  
  76.  
  77. Form2
  78.  
  79.  
  80. Dim myLS As New Class1
  81. Dim cat As String
  82. Dim Title As String
  83. Dim Author As String
  84. Dim Description As String
  85. Dim Category As String
  86.  
  87. Private Sub Command1_Click()
  88. myLS.Add Text1, Text2, Text3, Text4
  89. myLS.showdb Grid1
  90. End Sub
  91.  
  92. Private Sub Command2_Click()
  93. myLS.Update Text1, Text2, Text3, Text4
  94. myLS.showdb Grid1
  95. End Sub
  96.  
  97. Private Sub Command3_Click()
  98. myLS.Delete Text1
  99. myLS.showdb Grid1
  100. End Sub
  101.  
  102. Private Sub Command4_Click()
  103. Form2.Hide
  104. Form3.Show
  105.  
  106. End Sub
  107.  
  108. Private Sub Command5_Click()
  109. End
  110. End Sub
  111.  
  112. Private Sub Form_Load()
  113. Set myLS = New Class1
  114. myLS.showdb Grid1
  115.  
  116. cat = "Book Title"
  117. Option1.Value = True
  118. End Sub
  119.  
  120. Private Sub Grid1_DblClick()
  121. With Grid1
  122. .Col = 1
  123. Text1.Text = .Text
  124. Text1 = .Text
  125. .Col = 2
  126. Text2.Text = .Text
  127. .Col = 3
  128. Text3.Text = .Text
  129. .Col = 4
  130. Text4.Text = .Text
  131.  
  132.  
  133.  
  134. End With
  135. End Sub
  136.  
  137.  
  138.  
  139. Private Sub Option1_Click()
  140. cat = "Title"
  141. End Sub
  142.  
  143. Private Sub Option2_Click()
  144. cat = "Author"
  145. End Sub
  146.  
  147.  
  148. Private Sub Text1_KeyPress(KeyAscii As Integer)
  149. If KeyAscii = 13 Then
  150. Text2.SetFocus
  151. End If
  152. End Sub
  153.  
  154.  
  155. Private Sub Text2_KeyPress(KeyAscii As Integer)
  156. If KeyAscii = 13 Then
  157. Text3.SetFocus
  158. End If
  159. End Sub
  160.  
  161. Private Sub Text3_KeyPress(KeyAscii As Integer)
  162. If KeyAscii = 13 Then
  163. Text4.SetFocus
  164. End If
  165. End Sub
  166.  
  167.  
  168. Private Sub Text4_KeyPress(KeyAscii As Integer)
  169. If KeyAscii = 13 Then
  170. Text1.SetFocus
  171. End If
  172. End Sub
  173.  
  174. Private Sub Text5_Change()
  175. myLS.searchoption Grid1, cat, Text5
  176.  
  177. With Grid1
  178. .Col = 1
  179. Text1.Text = .Text
  180. Text = .Text
  181. .Col = 2
  182. Text2.Text = .Text
  183. .Col = 3
  184. Text3.Text = .Text
  185. .Col = 4
  186. Text4.Text = .Text
  187.  
  188. End With
  189. End Sub
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Form3
  196.  
  197.  
  198.  
  199.  
  200. Dim myLSS As New Class2
  201. Dim catt As String
  202. Dim UserID As String
  203. Dim Firstname As String
  204. Dim Lastname As String
  205. Dim Address As String
  206. Dim Age As String
  207. Dim Gender As String
  208. Dim IDNumber As String
  209. Dim Course As String
  210. Dim YearSection As String
  211. Dim Username As String
  212. Dim Password As String
  213.  
  214. Private Sub Command1_Click()
  215. myLSS.AddNa Text1, Text2, Text3, Text4, Text5, Text6, Text7, Text8, Text9, Text10, Text11
  216. myLSS.showdbb Grid2
  217. End Sub
  218.  
  219. Private Sub Command2_Click()
  220. myLSS.UpdateNa Text1, Text2, Text3, Text4, Text5, Text6, Text7, Text8, Text9, Text10, Text11
  221. myLSS.showdbb Grid2
  222. End Sub
  223.  
  224. Private Sub Command3_Click()
  225. myLSS.DeleteNa Text1
  226. myLSS.showdbb Grid2
  227. End Sub
  228.  
  229. Private Sub Form_Load()
  230. Set myLSS = New Class2
  231. myLSS.showdbb Grid2
  232.  
  233. catt = "Firstname"
  234. Option1.Value = True
  235. End Sub
  236.  
  237. Private Sub Grid2_DblClick()
  238. With Grid2
  239. .Col = 1
  240. Text1.Text = .Text
  241. Text1 = .Text
  242. .Col = 2
  243. Text2.Text = .Text
  244. .Col = 3
  245. Text3.Text = .Text
  246. .Col = 4
  247. Text4.Text = .Text
  248. .Col = 5
  249. Text5.Text = .Text
  250. .Col = 6
  251. Text6.Text = .Text
  252. .Col = 7
  253. Text7.Text = .Text
  254. .Col = 8
  255. Text8.Text = .Text
  256. .Col = 9
  257. Text9.Text = .Text
  258. .Col = 10
  259. Text10.Text = .Text
  260. .Col = 11
  261. Text11.Text = .Text
  262.  
  263. End With
  264. End Sub
  265.  
  266.  
  267.  
  268. Private Sub Option1_Click()
  269. catt = "Firstname"
  270. End Sub
  271.  
  272. Private Sub Option2_Click()
  273. catt = "Lastname"
  274. End Sub
  275.  
  276.  
  277.  
  278. Private Sub Text1_KeyPress(KeyAscii As Integer)
  279. If KeyAscii = 13 Then
  280. Text2.SetFocus
  281. End If
  282. End Sub
  283.  
  284.  
  285. Private Sub Text10_KeyPress(KeyAscii As Integer)
  286. If KeyAscii = 13 Then
  287. Text11.SetFocus
  288. End If
  289. End Sub
  290.  
  291.  
  292. Private Sub Text11_KeyPress(KeyAscii As Integer)
  293. If KeyAscii = 13 Then
  294. Text1.SetFocus
  295. End If
  296. End Sub
  297.  
  298. Private Sub Text12_Change()
  299. myLSS.searchoptionNa Grid2, catt, Text12
  300.  
  301. With Grid2
  302. .Col = 1
  303. Text1.Text = .Text
  304. Text1 = .Text
  305. .Col = 2
  306. Text2.Text = .Text
  307. .Col = 3
  308. Text3.Text = .Text
  309. .Col = 4
  310. Text4.Text = .Text
  311. .Col = 5
  312. Text5.Text = .Text
  313. .Col = 6
  314. Text6.Text = .Text
  315. .Col = 7
  316. Text7.Text = .Text
  317. .Col = 8
  318. Text8.Text = .Text
  319. .Col = 9
  320. Text9.Text = .Text
  321. .Col = 10
  322. Text10.Text = .Text
  323. .Col = 11
  324. Text11.Text = .Text
  325.  
  326. End With
  327. End Sub
  328.  
  329.  
  330.  
  331. Private Sub Text2_KeyPress(KeyAscii As Integer)
  332. If KeyAscii = 13 Then
  333. Text3.SetFocus
  334. End If
  335. End Sub
  336.  
  337.  
  338. Private Sub Text3_KeyPress(KeyAscii As Integer)
  339. If KeyAscii = 13 Then
  340. Text4.SetFocus
  341. End If
  342. End Sub
  343.  
  344.  
  345.  
  346. Private Sub Text4_KeyPress(KeyAscii As Integer)
  347. If KeyAscii = 13 Then
  348. Text5.SetFocus
  349. End If
  350. End Sub
  351.  
  352.  
  353. Private Sub Text5_KeyPress(KeyAscii As Integer)
  354. If KeyAscii = 13 Then
  355. Text6.SetFocus
  356. End If
  357. End Sub
  358.  
  359. Private Sub Text6_KeyPress(KeyAscii As Integer)
  360. If KeyAscii = 13 Then
  361. Text7.SetFocus
  362. End If
  363. End Sub
  364.  
  365.  
  366. Private Sub Text7_KeyPress(KeyAscii As Integer)
  367. If KeyAscii = 13 Then
  368. Text8.SetFocus
  369. End If
  370. End Sub
  371.  
  372.  
  373. Private Sub Text8_KeyPress(KeyAscii As Integer)
  374. If KeyAscii = 13 Then
  375. Text9.SetFocus
  376. End If
  377. End Sub
  378.  
  379. Private Sub Text9_KeyPress(KeyAscii As Integer)
  380. If KeyAscii = 13 Then
  381. Text10.SetFocus
  382. End If
  383. End Sub
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390. Module1
  391.  
  392.  
  393.  
  394. Public Function dbpath()
  395. dbpath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Documents\1AVisual Basic Output Files\Database\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
  396. End Function
  397.  
  398.  
  399.  
  400. Module2
  401.  
  402.  
  403.  
  404. Public Function dbpathh()
  405. dbpathh = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Documents\1AVisual Basic Output Files\Database\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
  406. End Function
  407.  
  408.  
  409.  
  410.  
  411. Module3
  412.  
  413.  
  414. Option Explicit
  415.  
  416.  
  417. Public con As ADODB.Connection
  418. Public Sub getconnected()
  419. Set con = New ADODB.Connection
  420. con.CursorLocation = adUseClient
  421. con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Desktop\Handouts\Final Library System\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
  422. con.Open
  423.  
  424. End Sub
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431. Class1
  432.  
  433.  
  434.  
  435. Dim rs As New ADODB.Recordset
  436. Dim conn As New ADODB.Connection
  437. Dim sql As String
  438. Private Sub Class_Initialize()
  439. Set rs = New ADODB.Recordset
  440. Set conn = New ADODB.Connection
  441.  
  442. conn.Open Module1.dbpath
  443.  
  444. With rs
  445. .LockType = adLockOptimistic
  446. .CursorLocation = adUseClient
  447. .CursorType = adOpenDynamic
  448.  
  449. End With
  450. End Sub
  451. Private Sub Class_Terminate()
  452. Set rs = Nothing
  453. Set conn = Nothing
  454.  
  455. End Sub
  456.  
  457. Public Function showdb(grd As MSHFlexGrid)
  458. If rs.State = 1 Then rs.Close
  459.  
  460. sql = "select*from tblLibrary"
  461. rs.Open sql, conn
  462. Set grd.DataSource = rs
  463.  
  464. End Function
  465.  
  466.  
  467. Public Function Add(Text1 As String, Text2 As String, Text3 As String, Text4 As String)
  468. If rs.State = 1 Then rs.Close
  469.  
  470. rs.Open sql, conn
  471. With rs
  472.  
  473. .AddNew
  474.  
  475. !Title = Text1
  476. !Author = Text2
  477. !Description = Text3
  478. !Category = Text4
  479.  
  480. .Update
  481. End With
  482. MsgBox "Yes Na Save !", vbOKOnly
  483.  
  484.  
  485. End Function
  486.  
  487. Public Function Update(Text1 As String, Text2 As String, Text3 As String, Text4 As String)
  488. If rs.State = 1 Then rs.Close
  489.  
  490. sql = "select*from tblLibrary where Title = '" & Text1 & "' "
  491. rs.Open sql, conn
  492. With rs
  493.  
  494. .Update
  495.  
  496.  
  497.  
  498. !Title = Text1
  499. !Author = Text2
  500. !Description = Text3
  501. !Category = Text4
  502.  
  503. .Update
  504.  
  505. End With
  506.  
  507. MsgBox "Updated Na !", vbOKOnly
  508.  
  509. End Function
  510.  
  511. Public Function Delete(Text1 As String)
  512. If rs.State = 1 Then rs.Close
  513.  
  514. sql = "Delete*from tblLibrary where Title= '" & Text1 & "' "
  515. rs.Open sql, conn
  516. MsgBox "Hala Nga a Gin DELETE mo !!", vbOKOnly
  517.  
  518. End Function
  519.  
  520. Public Function searchoption(grd As MSHFlexGrid, Category As String, Search As String)
  521. If rs.State = 1 Then rs.Close
  522.  
  523. sql = "select*from tblLibrary where " & Category & " like '%" & Search & "%'"
  524. rs.Open sql, conn
  525. Set grd.DataSource = rs
  526.  
  527. End Function
  528.  
  529.  
  530.  
  531. Class2
  532.  
  533.  
  534.  
  535. Dim rs As New ADODB.Recordset
  536. Dim conn As New ADODB.Connection
  537. Dim sql As String
  538. Private Sub Class_Initialize()
  539. Set rs = New ADODB.Recordset
  540. Set conn = New ADODB.Connection
  541.  
  542. conn.Open Module2.dbpathh
  543.  
  544. With rs
  545. .LockType = adLockOptimistic
  546. .CursorLocation = adUseClient
  547. .CursorType = adOpenDynamic
  548.  
  549. End With
  550. End Sub
  551. Private Sub Class_Terminate()
  552. Set rs = Nothing
  553. Set conn = Nothing
  554.  
  555. End Sub
  556.  
  557. Public Function showdbb(grd As MSHFlexGrid)
  558. If rs.State = 1 Then rs.Close
  559.  
  560. sql = "select*from tblUser"
  561. rs.Open sql, conn
  562. Set grd.DataSource = rs
  563.  
  564. End Function
  565. Public Function AddNa(Text1 As String, Text2 As String, Text3 As String, Text4 As String, Text5 As String, Text6 As String, Text7 As String, Text8 As String, Text9 As String, Text10 As String, Text11 As String)
  566.  
  567. If rs.State = 1 Then rs.Close
  568.  
  569. rs.Open sql, conn
  570. With rs
  571.  
  572. .AddNew
  573.  
  574. !Firstname = Text1
  575. !Lastname = Text2
  576. !MI = Text3
  577. !Address = Text4
  578. !Age = Text5
  579. !Gender = Text6
  580. !IDNumber = Text7
  581. !Course = Text8
  582. !YearSection = Text9
  583. !Username = Text10
  584. !Password = Text11
  585.  
  586.  
  587. .Update
  588. End With
  589. MsgBox "Yes Na Save !", vbOKOnly
  590.  
  591.  
  592. End Function
  593.  
  594. Public Function UpdateNa(Text1 As String, Text2 As String, Text3 As String, Text4 As String, Text5 As String, Text6 As String, Text7 As String, Text8 As String, Text9 As String, Text10 As String, Text11 As String)
  595. If rs.State = 1 Then rs.Close
  596.  
  597. sql = "select*from tblUser where Firstname = '" & Text1 & "' "
  598. rs.Open sql, conn
  599.  
  600. With rs
  601.  
  602. .Update
  603.  
  604. !Firstname = Text1
  605. !Lastname = Text2
  606. !MI = Text3
  607. !Address = Text4
  608. !Age = Text5
  609. !Gender = Text6
  610. !IDNumber = Text7
  611. !Course = Text8
  612. !YearSection = Text9
  613. !Username = Text10
  614. !Password = Text11
  615.  
  616. .Update
  617.  
  618. End With
  619.  
  620. MsgBox "Updated Na !", vbOKOnly
  621.  
  622. End Function
  623.  
  624. Public Function DeleteNa(Text1 As String)
  625. If rs.State = 1 Then rs.Close
  626.  
  627. sql = "Delete*from tblUser where Firstname= '" & Text1 & "' "
  628. rs.Open sql, conn
  629. MsgBox "Hala Nga a Gin DELETE mo !!", vbOKOnly
  630.  
  631. End Function
  632.  
  633. Public Function searchoptionNa(grd As MSHFlexGrid, Category As String, Search As String)
  634. If rs.State = 1 Then rs.Close
  635.  
  636. sql = "select*from tblUser where " & Category & " like '%" & Search & "%'"
  637. rs.Open sql, conn
  638. Set grd.DataSource = rs
  639.  
  640. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement