Hi experts,
I want your assistance in getting the loop correct.
"Taskpick" field in "tasks" table should be in between lfrm and lto fields of "ests" table
1) If the said condition is "not met" then vba should look for next record is ests table till this condition is met or till the end of ests table
how could I achieve it . I have upated question mark in the respective step
    
	
	
	
		
 I want your assistance in getting the loop correct.
"Taskpick" field in "tasks" table should be in between lfrm and lto fields of "ests" table
1) If the said condition is "not met" then vba should look for next record is ests table till this condition is met or till the end of ests table
how could I achieve it . I have upated question mark in the respective step
		Code:
	
	
	Set rsTask = CurrentDb.OpenRecordset("select * from tasks where employee is null order by taskpick;")
    With rsTask
            .MoveFirst
        Do While Not rsTask.EOF
            Set rsemp = CurrentDb.OpenRecordset("SELECT * FROM ests ORDER BY FreeAt", dbOpenSnapshot)
                rsemp.MoveFirst
                maxtme = DMax("[freeat]", "ests", "[Ename]='" & rsemp!ename & "'")
                Do While Not rsemp.EOF
                 If rsTask!taskpick >= rsemp!lfrm And rsTask!taskpick <= rsemp!lto Then
                     .Edit
                        !employee = rsemp!ename
                        ![freeat] = DateAdd("n", Nz(rsTask![tasktime]) * 60, maxtme)
                        .Update
                        Else
		[B][COLOR="Red"]???[/COLOR][/B]
                       
        
                 End If
                Loop
    
            rsTask.MoveNext
            rsemp.MoveNext
            If rsemp.EOF Then
            rsemp.MoveFirst
                        
                    End If
                    Loop
    End With
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	 
 
		 
 
		 
 
		