-----Original Message-----
I've written code to open a form, transfer values, then
close the form. The code works once. On 2nd (and
subsequent times) my values (on the form) are deleted
(after they have been transfered correctly)(like hitting
Esc) and an ASTERISK is in the record selector. I give up!
Thanks for any suggestions!
Ralph
.
Here's the code. If you are confused by the code at the
bottom; it is to remove the choices made on the listbox
(rowsource=" ", then re-populate (rowsource = SELECT...)
the values. This code has worked perfectly in an app I
wrote years ago (and is used daily by teachers). Thanks
for your help! Ralph
Private Sub cmdMultiAttendance_Click()
Dim intVar As Integer
Dim intPosition As Integer
Dim intNum As Integer
Dim strBuffer As Integer
Dim strRecipe As String
'Count # of selected items
intNum = Me!lstStudents.ItemsSelected.Count
'loop thru # of counts; 0 is first position!
For intVar = 0 To (intNum - 1)
'Get position of first,second,ect selection
intPosition = lstStudents.ItemsSelected(intVar)
'Get data from from above position
strBuffer = Me.lstStudents.ItemData(intPosition)
'Open frmMultiAttendence, transfer values
DoCmd.OpenForm "frmMainAttendance", , , , acFormAdd 'Opens
to new record
'Transfer StudentID from listbox
Forms!frmMainAttendance!txtStudentID = strBuffer
'Transfer Date of Absence
Forms!frmMainAttendance!txtDateOfAbsence =
Me.txtDateOfAbsence
'Transfer Reason for Absence
Forms!frmMainAttendance!txtReasonForAbsence =
Me.cboReasonForAbsence
'Transfer BehaviorPlan
Forms!frmMainAttendance!txtBehaviorPlan =
Me.cboBehaviorPlan
'Transfer Tardy
Forms!frmMainAttendance!ckTardy = Me.ckTardy
'Transfer Unexecused Absence
Forms!frmMainAttendance!ckUnexecused = Me.ckUnexecused
'close form after record is added
DoCmd.Close acForm, "frmMainAttendance"
Next intVar
'Blank out Listbox after adding exercises
Me.lstStudents.RowSource = " "
'restore row source
Me.lstStudents.RowSource = "SELECT NewStudentTable.ID,
NewStudentTable.[First Name], NewStudentTable.[Last Name],
NewStudentTable.GroupID FROM NewStudentTable WHERE
(((NewStudentTable.GroupID)=[Forms]![frmGroupMultiSelect]!
[lstGroups]));"
'Blank out attendance choices
Me.cboBehaviorPlan = " "
Me.cboReasonForAbsence = " "
Me.ckTardy = 0
Me.ckUnexecused = 0
End Sub