S
sherriross81
Hello,
I have a form that I am testing out a scenario to see if I am apply it to
other forms in my project. The form is called frmTest.
The form is bound to the table TestTable and has columns:
Primary Key , autonumber,
MonitorTknNbr, Number
ComputerTknNbr,Number
The form has a combo box that lists all the ComputerTknNbr and the List box
contains all of the MonitorTknNbrs. The user can select multiple values from
the list box of monitors but only one computer. If the user selects multiple
monitors I want it to insert a separate record in TestTable for each
computer/monitor combination.
I have looked through the discussion boards and found a few examples but I
am having trouble getting them to work so I thought I would post my code here
for some input. I am not sure if this is on the right track or not.....
Private Sub cboSave_Click()
Dim ctl As Control
Dim varItm As Variant
Set ctl = Me.lstMonitors
For Each varItm In ctl.ItemsSelected
DoCmd.GoToRecord acNewRec
Me.txtMonitorID = ctl.ItemData(varItm)
Me.txtComputerID = Me.cboComputerID.Value
Next varItm
Set ctl = Nothing
End Sub
When I run it I get a run time error 2487 The object type argument for the
action or method is blank or invalid.
I have a form that I am testing out a scenario to see if I am apply it to
other forms in my project. The form is called frmTest.
The form is bound to the table TestTable and has columns:
Primary Key , autonumber,
MonitorTknNbr, Number
ComputerTknNbr,Number
The form has a combo box that lists all the ComputerTknNbr and the List box
contains all of the MonitorTknNbrs. The user can select multiple values from
the list box of monitors but only one computer. If the user selects multiple
monitors I want it to insert a separate record in TestTable for each
computer/monitor combination.
I have looked through the discussion boards and found a few examples but I
am having trouble getting them to work so I thought I would post my code here
for some input. I am not sure if this is on the right track or not.....
Private Sub cboSave_Click()
Dim ctl As Control
Dim varItm As Variant
Set ctl = Me.lstMonitors
For Each varItm In ctl.ItemsSelected
DoCmd.GoToRecord acNewRec
Me.txtMonitorID = ctl.ItemData(varItm)
Me.txtComputerID = Me.cboComputerID.Value
Next varItm
Set ctl = Nothing
End Sub
When I run it I get a run time error 2487 The object type argument for the
action or method is blank or invalid.