W
worksfire1
I have a piece of code that I am trying to use to insert values from a
listbox on a form into a table, but I keep getting an error message:
"Microsoft Access can't find the field 'frmROEsList' referred to in your
expression."
It stops right at the line:
Set frm = form!frmROEsList
I thought this line is supposed to define the form, frmROEsList, but Access
is thinking there needs to be a field. Why/what field? I am trying to get
the data from the listbox.
Here is my code as is when a user clicks a line in the listbox:
Private Sub lstOracleLinesForROEs_Click()
Dim frm As Access.Form
Dim ctl As Control
Dim db As DAO.Database
Dim varItem As Variant
Set db = CurrentDb
Set frm = Form!frmROEsList
Set ctl = frm!lstOracleLinesForROEs
For Each varItem In ctl.ItemsSelected
db.Execute "INSERT INTO tblTest(Oracle#)" & " VALUES (""" &
ctl.ItemData(varItem) & """)"
Next varItem
End Sub
listbox on a form into a table, but I keep getting an error message:
"Microsoft Access can't find the field 'frmROEsList' referred to in your
expression."
It stops right at the line:
Set frm = form!frmROEsList
I thought this line is supposed to define the form, frmROEsList, but Access
is thinking there needs to be a field. Why/what field? I am trying to get
the data from the listbox.
Here is my code as is when a user clicks a line in the listbox:
Private Sub lstOracleLinesForROEs_Click()
Dim frm As Access.Form
Dim ctl As Control
Dim db As DAO.Database
Dim varItem As Variant
Set db = CurrentDb
Set frm = Form!frmROEsList
Set ctl = frm!lstOracleLinesForROEs
For Each varItem In ctl.ItemsSelected
db.Execute "INSERT INTO tblTest(Oracle#)" & " VALUES (""" &
ctl.ItemData(varItem) & """)"
Next varItem
End Sub