S
SF
Hi,
I have an entry form consist of two listboxes, one for districts and another
one for communes. Both listboxes is set to allow multiple selection. Based
on the selected communes, I want to add these record to a table, my table
consist of 4 fields, \
ID AutoNumber
P_ObjectID Number Foreign key
P_DistrictID Number
P_CommuneID Number Foreigh Key link to Commune Table
My Commune Listbox has 3 columns
CommuneID;Commune Name;District Code
Thorugh code below, I get Object Not found!
Dim varItem As Variant
Dim dbs As DAO.Database
Dim rstLocation As DAO.Recordset
Set dbs = CurrentDb
Set rstLocation = dbs.OpenRecordset("tblProjectLocations", dbOpenDynaset)
With rstLocation
For Each varItem In Me.lstCommuneID.ItemsSelected
.AddNew
![P_ObjectID] = 5 'varObjectID
![P_DistrictID] = Me.lstCommuneID.Column(2).ItemData(varItem)
=============> I get error here
'.Column(2) ' .Column(2)
![P_CommuneID] = Me.lstCommuneID.ItemData(varItem) '.Column(0)
.Update
Next varItem
End With
I have an entry form consist of two listboxes, one for districts and another
one for communes. Both listboxes is set to allow multiple selection. Based
on the selected communes, I want to add these record to a table, my table
consist of 4 fields, \
ID AutoNumber
P_ObjectID Number Foreign key
P_DistrictID Number
P_CommuneID Number Foreigh Key link to Commune Table
My Commune Listbox has 3 columns
CommuneID;Commune Name;District Code
Thorugh code below, I get Object Not found!
Dim varItem As Variant
Dim dbs As DAO.Database
Dim rstLocation As DAO.Recordset
Set dbs = CurrentDb
Set rstLocation = dbs.OpenRecordset("tblProjectLocations", dbOpenDynaset)
With rstLocation
For Each varItem In Me.lstCommuneID.ItemsSelected
.AddNew
![P_ObjectID] = 5 'varObjectID
![P_DistrictID] = Me.lstCommuneID.Column(2).ItemData(varItem)
=============> I get error here
'.Column(2) ' .Column(2)
![P_CommuneID] = Me.lstCommuneID.ItemData(varItem) '.Column(0)
.Update
Next varItem
End With