Guest User

Untitled

a guest
Feb 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. Private Sub cmdAddPosition_Click()
  2.  
  3. Dim i As Integer
  4.  
  5. Me.lstAddPositions.ColumnCount = 7
  6.  
  7. If Me.txtAddPos.Value = i And i > 0 And i < 50 Then
  8. Me.lstAddPositions.AddItem (Me.txtAddPos.Value)
  9. 'Me.lstAddPositions.AddItem(Me.txtAddPos.Value,(i))
  10. Me.lstAddPositions.List(0, i) = Me.txtAddPos.Value
  11. 'Me.lstAddPositions.Column(0, i) = Me.txtAddPos.Value 'adding number of position
  12. 'Me.lstAddPositions.Column(2, i) = Me.lstAddHidden.Column(0, 0) 'adding titel
  13. End If
  14.  
  15. Me.lstAddPositions.Requery
  16.  
  17. End Sub
  18.  
  19. Private Sub cmdAddPosition_Click()
  20. Dim i As Integer
  21.  
  22. Me.lstAddPositions.ColumnCount = 7
  23.  
  24. If Me.txtAddPos.Value = i And i > 0 And i < 50 Then
  25. Me.lstAddPositions.AddItem "Col1" & "," & "col2" & "," & "Col3" & "," & _
  26. "Col4" & "," & "Col5" & "," & "col6" & "," & "col7" &";"
  27. End If
  28.  
  29. Me.lstAddPositions.Requery
  30. End Sub
  31.  
  32. DROP TABLE Test;
  33. CREATE TABLE Test (TestID AUTOINCREMENT(1, 1),
  34. TestName TEXT,
  35. TestDescription TEXT,
  36. CONSTRAINT TestPKey PRIMARY KEY (TestID));
  37. INSERT INTO Test (TestName, TestDescription)
  38. VALUES ('Test A', 'Testing Record A')";
  39. INSERT INTO Test (TestName, TestDescription)
  40. VALUES ('Test B', 'Testing Record B')";
  41. INSERT INTO Test (TestName, TestDescription)
  42. VALUES ('Test C', 'Testing Record C')";
  43.  
  44. Private Sub TestButton_Click()
  45. Dim rst As DAO.Recordset
  46. Dim fld As DAO.Field
  47. Dim lb As ListBox
  48. Dim rowStr As String
  49.  
  50. Set rst = CurrentDb.OpenRecordset("Test")
  51. Set lb = Me.TestListBox
  52.  
  53. ' Set the number of listbox columns to reflect recordset fields
  54. lb.ColumnCount = rst.Fields.Count
  55. ' Set the row source type to Value List
  56. lb.RowSourceType = "Value List"
  57. ' Erase the listbox data so we can populate it
  58. lb.RowSource = ""
  59.  
  60. ' If ColumnHeads property is enabled, then first record is field
  61. ' names. Lets populate those.
  62. If lb.ColumnHeads Then
  63. rowStr = ""
  64. ' Build a string for each record
  65. For Each fld In rst.Fields
  66. rowStr = rowStr & replace(fld.Name,",","") & ","
  67. Next
  68. ' Strip final comma
  69. rowStr = Left(rowStr, Len(rowStr) - 1)
  70. ' Add each record (all fields) at once.
  71. lb.AddItem rowStr
  72. End If
  73.  
  74. ' Loop through each record
  75. Do Until rst.EOF
  76. ' Build a record string and add it
  77. rowStr = ""
  78. For Each fld In rst.Fields
  79. rowStr = rowStr & replace(fld.Value,",","") & ","
  80. Next
  81. rowStr = Left(rowStr, Len(rowStr) - 1)
  82. lb.AddItem rowStr
  83. rst.MoveNext
  84. Loop
  85.  
  86. ' Close and release objects
  87. rst.Close
  88. Set fld = Nothing
  89. Set rst = Nothing
  90. Set lb = Nothing
  91. End Sub
  92.  
  93. Me.listbox2.AddItem (Me.listbox1.Column(0) & ";" & Me.listbox1.Column(1))
  94.  
  95. Dim strName as string
  96. strName=String1&";"&String2
  97. Me.listName.addItem strName
Add Comment
Please, Sign In to add comment