• We just launched and are currently in beta. Join us as we build and grow the community.

Populating Elements

Louby

System Optimizer
L Rep
0
0
0
Rep
0
L Vouches
0
0
0
Vouches
0
Posts
120
Likes
16
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
  1. Option

    Explicit
  2. Dim

    conn As

    ADODB.Connection
  3. Dim

    rs As

    ADODB.Recordset




  4. ' pupulate element
  5. ' @author: Kevern
  6. ' @date: checkDate 07/28/2009
  7. Public

    Sub

    init()
  8. Set

    conn = New

    ADODB.Connection
  9. Set

    rs = New

    ADODB.Recordset
  10. conn.connectionString = ConnectionStringModule.connectionString
  11. With

    conn
  12. On

    Error

    GoTo

    errHandler
  13. .Open
  14. End

    With
  15. Exit

    Sub
  16. errHandler:
  17. MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element MOdule - Init"
  18. End

    Sub
  19. Public

    Sub

    populateFlexGrids(dboquery As

    String

    , grid As

    MSHFlexGrid)
  20. Call

    init
  21. grid.Clear
  22. With

    rs
  23. On

    Error

    GoTo

    errHandler
  24. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  25. If

    rs.RecordCount = 0 Then
  26. MsgBox "No Data Found!"

    , vbCritical, "Admin: Populate Element MOdule - Populate Flexgrid"
  27. Set

    grid.DataSource = rs
  28. Else
  29. Set

    grid.DataSource = rs
  30. End

    If
  31. .Close
  32. End

    With
  33. conn.Close
  34. Dim

    columnWidth As

    Double
  35. Dim

    counter As

    Integer
  36. columnWidth = (grid.Width / grid.Cols)
  37. If

    columnWidth <= 2000 Then
  38. columnWidth = 2000
  39. End

    If
  40. For

    counter = 0 To

    grid.Cols
  41. grid.ColWidth(counter) = columnWidth
  42. Next

    counter
  43. grid.Refresh
  44. Exit

    Sub
  45. errHandler:
  46. MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element MOdule - Populate Flexgrid: Error"
  47. End

    Sub
  48. Public

    Sub

    populatePickingList(dboquery As

    String

    , grid As

    MSHFlexGrid)
  49. Call

    init
  50. grid.Clear
  51. With

    rs
  52. On

    Error

    Resume

    Next
  53. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  54. Set

    grid.DataSource = rs
  55. .Close
  56. End

    With

  57. Dim

    counter As

    Integer
  58. With

    grid
  59. For

    counter = 0 To

    grid.Cols - 1
  60. .ColWidth(counter) = 2000
  61. Next

    counter
  62. End

    With

  63. conn.Close
  64. End

    Sub
  65. Public

    Sub

    populateCombo(KeyToCollect As

    String

    , dboquery As

    String

    , combo As

    ComboBox)
  66. Call

    init
  67. combo.Clear
  68. With

    rs
  69. 'On Error GoTo errHandler
  70. On

    Error

    Resume

    Next
  71. If

    .State = adStateClosed Then
  72. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  73. End

    If
  74. Do

    While

    Not

    .EOF
  75. combo.addItem .fields(KeyToCollect)
  76. .MoveNext
  77. Loop
  78. .Close
  79. End

    With
  80. conn.Close
  81. Exit

    Sub
  82. errHandler:
  83. MsgBox Err.Description, vbCritical + vbOKOnly, " Admin: Populate Element MOdule - Populate Combo: Error"
  84. End

    Sub
  85. Public

    Sub

    setText(dboquery As

    String

    , txtBox As

    TextBox, fieldCollect As

    String

    )
  86. Call

    init
  87. With

    rs
  88. 'On Error GoTo errHandler
  89. On

    Error

    Resume

    Next
  90. If

    .State = adStateClosed Then
  91. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  92. End

    If
  93. If

    .EOF Then
  94. MsgBox "Request unavailable on other tables, cannot populate other elements!"
  95. .Close
  96. conn.Close
  97. Exit

    Sub
  98. Else
  99. txtBox.Text = .fields(fieldCollect)
  100. End

    If

  101. .Close
  102. End

    With
  103. conn.Close
  104. Exit

    Sub
  105. errHandler:
  106. MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element MOdule - Set Text: Error"
  107. End

    Sub
  108. Public

    Sub

    setcomboText(dboquery As

    String

    , cbo As

    ComboBox, fieldCollect As

    String

    )
  109. Call

    init
  110. With

    rs
  111. 'On Error GoTo errHandler
  112. On

    Error

    Resume

    Next
  113. If

    .State = adStateClosed Then
  114. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  115. End

    If
  116. If

    .EOF Then
  117. MsgBox "Request unavailable on other tables, cannot populate other elements!"
  118. .Close
  119. conn.Close
  120. cbo.Text = ""
  121. Exit

    Sub
  122. Else
  123. cbo.Text = .fields(fieldCollect)
  124. End

    If
  125. .Close
  126. End

    With
  127. conn.Close
  128. Exit

    Sub
  129. errHandler:
  130. MsgBox Err.Description, vbCritical + vbOKOnly, "Admin: Populate Element MOdule - Set Combo: Error"
  131. End

    Sub
  132. Public

    Sub

    setDate(dboquery As

    String

    , DTP As

    DTPicker, fieldCollect As

    String

    )
  133. Call

    init
  134. With

    rs
  135. On

    Error

    GoTo

    errHandler
  136. .Open

    dboquery, conn, adOpenKeyset, adLockOptimistic
  137. DTP.value = .fields(fieldCollect)
  138. .Close
  139. End

    With
  140. conn.Close
  141. Exit

    Sub
  142. errHandler:
  143. MsgBox Err.Description, vbCritical + vbOKOnly, " Admin: Populate Element MOdule - Set Date: Error"
  144. End

    Sub

 

440,010

316,559

316,568

Top