alastair69
Registered User.
- Local time
- Yesterday, 21:57
- Joined
- Dec 21, 2004
- Messages
- 562
Hello Once More,
I am trying to populate a list view and for some reason, all i get is a blank list view.
I am using the code below to generate the item into a form called "JT History Sub" the table is called JT History and has the following fields:
HistoryID = AutoNumber (PK)
ClientID = Text (50)
Description = Text (255)
UserID = Text (50)
HistoryDate = Date/Time
Code Used :-
Private Sub Form_Current()
Dim dbs As Database, rst As Recordset, strSQL As String, intLoop As Long, intCount As Long
Dim itmX As ListItem
Set dbs = CurrentDb
strSQL = "SELECT * FROM [" & Me.RecordSource & "] WHERE clientID = '" & Me.ClientID & "';"
Set rst = dbs.OpenRecordset(strSQL)
Me.ListView.ListItems.Clear
On Error GoTo NoRecords
rst.MoveLast
intCount = rst.RecordCount
If intCount > 0 Then
rst.MoveFirst
For intLoop = 0 To intCount - 1
Set itmX = ListView.ListItems.Add()
If rst("Event") = "E-Mailed" Then itmX.SmallIcon = 1
If Left$(rst("Event"), 7) = "Printed" Then itmX.SmallIcon = 2
If rst("Event") = "Locked" Then itmX.SmallIcon = 3
If rst("Event") = "Unlocked" Then itmX.SmallIcon = 4
itmX.Text = rst("Event")
itmX.SubItems(1) = Format(rst("EventDate"), "hh:nn:ss ddd , mmmm dd, yyyy")
itmX.SubItems(2) = rst("User")
rst.MoveNext
Next intLoop
End If
NoRecords:
End Sub
Can anybody help me out please
Alastair
I am trying to populate a list view and for some reason, all i get is a blank list view.
I am using the code below to generate the item into a form called "JT History Sub" the table is called JT History and has the following fields:
HistoryID = AutoNumber (PK)
ClientID = Text (50)
Description = Text (255)
UserID = Text (50)
HistoryDate = Date/Time
Code Used :-
Private Sub Form_Current()
Dim dbs As Database, rst As Recordset, strSQL As String, intLoop As Long, intCount As Long
Dim itmX As ListItem
Set dbs = CurrentDb
strSQL = "SELECT * FROM [" & Me.RecordSource & "] WHERE clientID = '" & Me.ClientID & "';"
Set rst = dbs.OpenRecordset(strSQL)
Me.ListView.ListItems.Clear
On Error GoTo NoRecords
rst.MoveLast
intCount = rst.RecordCount
If intCount > 0 Then
rst.MoveFirst
For intLoop = 0 To intCount - 1
Set itmX = ListView.ListItems.Add()
If rst("Event") = "E-Mailed" Then itmX.SmallIcon = 1
If Left$(rst("Event"), 7) = "Printed" Then itmX.SmallIcon = 2
If rst("Event") = "Locked" Then itmX.SmallIcon = 3
If rst("Event") = "Unlocked" Then itmX.SmallIcon = 4
itmX.Text = rst("Event")
itmX.SubItems(1) = Format(rst("EventDate"), "hh:nn:ss ddd , mmmm dd, yyyy")
itmX.SubItems(2) = rst("User")
rst.MoveNext
Next intLoop
End If
NoRecords:
End Sub
Can anybody help me out please
Alastair