RE: Adding multiple records based on a list box
- From: Beetle <Beetle@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Oct 2008 15:11:02 -0700
Stop!
If one computer can have multiple monitors associated with it then
those two entities shuold be in separate tables in a 1:m relationship.
Access is a relational database, not a spreadsheet. What you're doing
now is basically trying to feed it spreadsheet data.
Once you have your tables correctly designed, you can set up a
main form/sub form where the users can select as many monitors as they
need for any given computer. No code will be necessary.
--
_________
Sean Bailey
"sherriross81" wrote:
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.
- Follow-Ups:
- RE: Adding multiple records based on a list box
- From: sherriross81
- RE: Adding multiple records based on a list box
- References:
- Adding multiple records based on a list box
- From: sherriross81
- Adding multiple records based on a list box
- Prev by Date: Adding multiple records based on a list box
- Next by Date: Timesheet Input Form
- Previous by thread: Adding multiple records based on a list box
- Next by thread: RE: Adding multiple records based on a list box
- Index(es):
Relevant Pages
|