greaseman
Closer to seniority!
- Local time
- Today, 17:38
- Joined
- Jan 6, 2003
- Messages
- 360
I've got a form with one subform. What the form attempts is to allow users to choose one or many courses in which to enroll one or many students. It doesn't work. What I want to have happen is when the user presses a SAVE button, to have it go through each course (in a Course table) and add the first course chosen, and then to have it go through each student chosen (in a related Student table); next, if more than one course is chosen to have the whole thing repeat the process. Here's a snippet I'm trying to use in my process:
Private Sub cmdSave_Click()
Dim iNumLstRows1 As Integer
Dim iPtr1 As Integer
With Me.LstCourses
iNumLstRows1 = .ListCount - 1
For iPtr1 = 0 To iNumLstRows1
If .Selected(iPtr1) Then
Me.txtCourseId = .Column(0, iPtr1)
Me.txtCourseName = .Column(1, iPtr1)
Me.Requery
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
Next iPtr1
DBEngine.Idle
.Requery
End With
DoCmd.GoToRecord , , acNewRec
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
The part I'm confused about is it seems to go through the code, but only the last course chosen seems to work, not other courses.
Am I going about this the right way? Is there something out there that actually works?
Thanks in advance to those willing to help break a brain block.
Private Sub cmdSave_Click()
Dim iNumLstRows1 As Integer
Dim iPtr1 As Integer
With Me.LstCourses
iNumLstRows1 = .ListCount - 1
For iPtr1 = 0 To iNumLstRows1
If .Selected(iPtr1) Then
Me.txtCourseId = .Column(0, iPtr1)
Me.txtCourseName = .Column(1, iPtr1)
Me.Requery
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
Next iPtr1
DBEngine.Idle
.Requery
End With
DoCmd.GoToRecord , , acNewRec
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
The part I'm confused about is it seems to go through the code, but only the last course chosen seems to work, not other courses.
Am I going about this the right way? Is there something out there that actually works?
Thanks in advance to those willing to help break a brain block.