Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Dim conn As ADODB.Connection
  2. Dim rs As ADODB.Recordset
  3.  
  4. Private Sub Form_Load()
  5. Set conn = New ADODB.Connection
  6. conn.Open CurrentProject.Connection
  7.  
  8. Set rs = New ADODB.Recordset
  9. With rs
  10. rs.CursorLocation = adUseClient
  11. rs.Open "select * from amsPor", conn, adOpenStatic, adLockBatchOptimistic
  12. Set rs.ActiveConnection = Nothing
  13. End With
  14. Set Me.Recordset = rs
  15. conn.Close
  16. End Sub
  17.  
  18. Private Sub Form_Unload(Cancel As Integer)
  19. Select Case MsgBox("Save changes ?", vbQuestion + vbYesNoCancel)
  20. Case vbNo
  21. 'do nothing
  22. Case vbYes
  23. conn.Open CurrentProject.Connection
  24. rs.ActiveConnection = conn
  25. rs.UpdateBatch
  26. rs.Close
  27. Set conn = Nothing
  28. Case vbCancel
  29. Cancel = True
  30. End Select
  31. End Sub
  32.  
  33. Sub Randomise
  34. Randomize
  35. Set rs = CreateObject("ADODB.Recordset")
  36. With rs
  37. .Fields.Append "RandomNumber", 4
  38.  
  39. .Fields.Append "Txt", 201, 5000
  40. .Open
  41. Do Until Inp.AtEndOfStream
  42. .AddNew
  43. .Fields("RandomNumber").value = Rnd() * 10000
  44. .Fields("Txt").value = Inp.readline
  45. .UpDate
  46. Loop
  47. .Sort = "RandomNumber"
  48. Do While not .EOF
  49. Outp.writeline .Fields("Txt").Value
  50.  
  51. .MoveNext
  52. Loop
  53. End With
  54. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement