Loop through records, pop up window for data and insert

  • Thread starter Thread starter steamngn via AccessMonster.com
  • Start date Start date
S

steamngn via AccessMonster.com

Hi All!
Is it possible to loop through records and pop up a window for additional
data, then insert the record? at present I have this:
Dim SQLStr As String
If MySelected2 <> "" Then
SQLStr = "INSERT INTO ATTENDANCE (ATT_HDR_ID,STUDENT_ID,EVENT_ID,LOCATION_ID,
EVENT_DAT,COMMENT,PHYSICAL_LIMITS,EVENT_FEE) SELECT " & Forms!ATTENDANCE_HDR.
ATT_HDR_ID & " as ATT_HDR_ID, STUDENTS.STUDENT_ID AS STUDENT_ID," & Forms!
ATTENDANCE_HDR.EVENT_ID & " as EVENT_ID," & Forms!ATTENDANCE_HDR.LOCATION_ID
& " AS LOCATION_ID,'" & Forms!ATTENDANCE_HDR.EVENT_DAT & "' as EVENT_DAT, '',
'',0 FROM STUDENTS WHERE STUDENT_ID IN (" & MySelected2 & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL (SQLStr)
DoCmd.SetWarnings True
Set colCheckBox = Nothing
Me.Requery
Forms!ATTENDANCE_HDR!sfmstudentclasslist.Requery
End If
inserting records just fine. But some of our classes require fees, and I
would like to pop up a small form to add the amount (different for each
student) and then insert each record.
Yes? No? better ideas?
Thank you
Andy
 
Yes, is is possible to do what you want. Your code does not seen to the
complete code for the event/sub/function.

Where is this code?

What is "MySelected2"?

How will you know what recordset to loop through?
Hi All!
Is it possible to loop through records and pop up a window for additional
data, then insert the record? at present I have this:
Dim SQLStr As String
If MySelected2 <> "" Then
SQLStr = "INSERT INTO ATTENDANCE (ATT_HDR_ID,STUDENT_ID,EVENT_ID,LOCATION_ID,
EVENT_DAT,COMMENT,PHYSICAL_LIMITS,EVENT_FEE) SELECT " & Forms!ATTENDANCE_HDR.
ATT_HDR_ID & " as ATT_HDR_ID, STUDENTS.STUDENT_ID AS STUDENT_ID," & Forms!
ATTENDANCE_HDR.EVENT_ID & " as EVENT_ID," & Forms!ATTENDANCE_HDR.LOCATION_ID
& " AS LOCATION_ID,'" & Forms!ATTENDANCE_HDR.EVENT_DAT & "' as EVENT_DAT, '',
'',0 FROM STUDENTS WHERE STUDENT_ID IN (" & MySelected2 & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL (SQLStr)
DoCmd.SetWarnings True
Set colCheckBox = Nothing
Me.Requery
Forms!ATTENDANCE_HDR!sfmstudentclasslist.Requery
End If
inserting records just fine. But some of our classes require fees, and I
would like to pop up a small form to add the amount (different for each
student) and then insert each record.
Yes? No? better ideas?
Thank you
Andy

--
Boyd Trimmell
aka HiTechCoach
http://www.hitechcoach.com
http://www.officeprogramming.com

Message posted via AccessMonster.com
 
Boyd said:
Yes, is is possible to do what you want. Your code does not seen to the
complete code for the event/sub/function.

Where is this code?

What is "MySelected2"?

How will you know what recordset to loop through?
Hi All!
Is it possible to loop through records and pop up a window for additional
[quoted text clipped - 20 lines]
Thank you
Andy
Hey Boyd,
MySelected2 is a function that loops through checked names and builds a
string like "where student_id in (1,2,3)"
I think I came up with a better solution, though, that will prevent the user
from inserting bogus data. Thanks for the look though!
Andy
 
Back
Top