JonnyCav
Member
I've been at this for 8 hours!  Instead of each checkbox being submitted individually to my sqlite database I'm trying to put them into a map (for each checked) and then (hopefully) insert them under one button click.
The 'map' seems to be working correctly (key gets updated and the array is correct. But when I try to go through them as per Erel's 'For Each...' it only returns the last checked entry (albeit in the correct format/key number)
(When the checkbox is checked LOG) returns
(MyMap) {4=[87, ME21, Алферова Ольга, 03-01-24, 4, P]}
(MyMap) {5=[88, ME21, Ашыров Шаназар, 03-01-24, 4, P]}
(MyMap) {6=[89, ME21, Горяинова Яна, 03-01-24, 4, P]}
(For Each.....) returns
[89, ME21, Горяинова Яна, 03-01-24, 4, P]
Can anyone spot my (probably blatant) mistake?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			The 'map' seems to be working correctly (key gets updated and the array is correct. But when I try to go through them as per Erel's 'For Each...' it only returns the last checked entry (albeit in the correct format/key number)
(When the checkbox is checked LOG) returns
(MyMap) {4=[87, ME21, Алферова Ольга, 03-01-24, 4, P]}
(MyMap) {5=[88, ME21, Ашыров Шаназар, 03-01-24, 4, P]}
(MyMap) {6=[89, ME21, Горяинова Яна, 03-01-24, 4, P]}
(For Each.....) returns
[89, ME21, Горяинова Яна, 03-01-24, 4, P]
Can anyone spot my (probably blatant) mistake?
			
				B4X:
			
		
		
		rivate Sub cbStudents_CheckedChange(Checked As Boolean)
'WORKING CODE BELOW
    Dim index As Int = clvAttendance.GetItemFromView(Sender)
    Dim p As B4XView =clvAttendance.GetPanel(index)
    Dim CB As CheckBox = Sender
    
    'Dim records As Map
    records.Initialize
    counter=counter+1
    
    
    Dim studentsToAdd As List
    studentsToAdd.Initialize
    
    If CB.Checked  Then
        lblstudentID=(p.GetView(0).Text)
        
        studentsToAdd.AddAll(Array(lblstudentID,selectedGroup,CB.Text, txtClassDate.Text, txtClassPeriod.Text, "P"))
        records.Put(counter,studentsToAdd)
        
    End If   
'Log(studentsToAdd)
Log(records)
'***** WORKING for individual CHECKS on CHECKBOXES ************
    'Starter.sql.ExecNonQuery2("INSERT INTO attendance VALUES (?, ?, ? ,?, ?, ?,null)", Array As Object(lblstudentID, selectedGroup, CB.Text, txtClassDate.Text, txtClassPeriod.Text, "P"))
        
    ToastMessageShow("Entry added", False)
'**************************************************************
End Sub
'MAIN SUB PAGE  - ATTENDANCE STEP 5 
'SUbmit all data to ATTENDANCE and UPDATE the 'classCount' table
Private Sub btnUpdateAttendance_Click
    
    'TEST OF MAP (records) **********
    
    For Each k As Int In records.Keys
        Dim v As String = records.Get(k)
        Log(v)
    Next
    ...... 
				 
 
		 
 
		 
 
		 
 
		