This is the code I am using to insert into a table, and show selection in
another list box:
CurrentDb.Execute "INSERT INTO tblMovement (EmpID, SupervisorID,
CurrentSupervisorID, CurrentADID, ADID, InsertDate, EffectiveDate,
CurrentUser) " & _
"VALUES (" & lstSelectEmp.Column(0) & ", " &
cboNewSupervisor.Column(0) & ", " & cboCurrentSupervisor.Column(0) & ", " &
cboCurrentSupervisor.Column(2) & ", " & cboNewSupervisor.Column(2) & ", " &
Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _
"," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ",
" & Chr$(34) & txtCurrentUser & Chr$(34) & ")"
I'm not sure what you're doing with your Insert statement; do you want to insert EACH selected item in lstSelectEmp into
tblMovement? If so, build the For - Next loop, and stick your INSERT statement into it:
Dim var as Variant
For each var in lstSelectEmp.ItemsSelected
CurrentDb.Execute "INSERT INTO tblMovement (EmpID, SupervisorID,
CurrentSupervisorID, CurrentADID, ADID, InsertDate, EffectiveDate,
CurrentUser) VALUES (" & lstSelectEmp.Column(0, var) & ", " &
cboNewSupervisor.Column(0) & ", " & cboCurrentSupervisor.Column(0) & ", " &
cboCurrentSupervisor.Column(2) & ", " & cboNewSupervisor.Column(2) & ", " &
Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", "
& Chr$(34) & txtCurrentUser & Chr$(34) & ")"
Next var
Note that I added the "var" to the lstSelectEmp.Column section ...
If that's not what you're trying to do, please explain further.
Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com