D
dk
I have tblCompanies
IDCompany (text,4,Index,Unique)
Name(text)
Adress(Text)
Phone(Text)
Id like to present all members into
OLE class=ListViewCtrl
Class=MSComctlLib.ListViewCtrl.2
I using following code to fill data:
Option Compare Database
Option Explicit
Private mrstCompanies As Recordset
Private mobjListItems As ListItems
Private Sub Form_Load()
Call OpenCompanyRecordset
Call LoadListViewHeaders
Call loadListViewData
End Sub
Private Sub LoadListViewHeaders()
Dim objListItem As ListItem
Set mobjListItems = Me.objListWiew.ListItems
With Me.objListWiew
.View = lvwReport
With .ColumnHeaders
.Add , , "Name", 2880
.Add , , "Address", 1440
.Add , , "Phone", 1300
End With
End With
End Sub
Private Sub loadListViewData()
mobjListItems.Clear
Dim objListItem As ListItem
mrstCompanies.MoveFirst
Do Until mrstCompanies.EOF
Set objListItem = mobjListItems.Add(, mrstCompanies!IDCompany,
mrstCompanies!Name)
With objListItem
.SubItems(1) = mrstCompanies!Address
.SubItems(2) = mrstCompanies!Phone
End With
mrstCompanies.MoveNext
Loop
End Sub
Private Sub OpenCompanyRecordset()
Dim db As Database
Set db = CurrentDb()
Set mrstCompanies = db.OpenRecordset("tblCompanies", dbOpenDynaset)
End Sub
I allways get error "Invalid key" in
private sub loadListViewData row "Set objListItem = mobjListItems.Add(,
mrstCompanies!IDCompany, mrstCompanies!Name)"
Please I need Your suggestion to resolve problem.
Regards,
DK
IDCompany (text,4,Index,Unique)
Name(text)
Adress(Text)
Phone(Text)
Id like to present all members into
OLE class=ListViewCtrl
Class=MSComctlLib.ListViewCtrl.2
I using following code to fill data:
Option Compare Database
Option Explicit
Private mrstCompanies As Recordset
Private mobjListItems As ListItems
Private Sub Form_Load()
Call OpenCompanyRecordset
Call LoadListViewHeaders
Call loadListViewData
End Sub
Private Sub LoadListViewHeaders()
Dim objListItem As ListItem
Set mobjListItems = Me.objListWiew.ListItems
With Me.objListWiew
.View = lvwReport
With .ColumnHeaders
.Add , , "Name", 2880
.Add , , "Address", 1440
.Add , , "Phone", 1300
End With
End With
End Sub
Private Sub loadListViewData()
mobjListItems.Clear
Dim objListItem As ListItem
mrstCompanies.MoveFirst
Do Until mrstCompanies.EOF
Set objListItem = mobjListItems.Add(, mrstCompanies!IDCompany,
mrstCompanies!Name)
With objListItem
.SubItems(1) = mrstCompanies!Address
.SubItems(2) = mrstCompanies!Phone
End With
mrstCompanies.MoveNext
Loop
End Sub
Private Sub OpenCompanyRecordset()
Dim db As Database
Set db = CurrentDb()
Set mrstCompanies = db.OpenRecordset("tblCompanies", dbOpenDynaset)
End Sub
I allways get error "Invalid key" in
private sub loadListViewData row "Set objListItem = mobjListItems.Add(,
mrstCompanies!IDCompany, mrstCompanies!Name)"
Please I need Your suggestion to resolve problem.
Regards,
DK