This cmdUpdate code uses the TOP predicate value entered in TEXTBOX1 to select “scattered” records throughout a filtered list (see list Select statement below).
Code:
Private Sub cmdUpdate_Click()Dim strSQL As String
strSQL = "UPDATE Students SET Students.UpdateGroupAdvisingApt = -1 "
strSQL = strSQL & "WHERE Students.[ID] IN "
strSQL = strSQL & "(SELECT TOP " & CLng(Me.Textbox1) & " [ID] FROM Students As S "
strSQL = strSQL & "WHERE ((S.GroupAdvisingSessionID) is null) AND (S.Flightpath) = [Forms]![SCHEDULERFlightpath]![cboFlightPathList] " '
strSQL = strSQL & "AND (S.Session = " & Val([Forms]![SelectSessionFlightpath]![SessionCombo] & "") & "));"
fExecuteQuery strSQL, dbFailOnError
Me.Textbox1 = Null
DoCmd.Requery
End Sub
Form Select statement:
Code:
SELECT Students.Major, Students.UpdateGroupAdvisingApt, [Last] & ", " & [First] AS StudentName, Students.ID, Students.Session, Students.FlightPath, Students.GroupAdvisingSessionID, Students.SSN
FROM [Group Advising] RIGHT JOIN Students ON [Group Advising].GroupAdvisingRecordID = Students.GroupAdvisingSessionID
WHERE (((Students.Session)=[Forms]![SelectSessionFlightpath]![SessionCombo]) AND ((Students.FlightPath)=[Forms]![SCHEDULERFlightpath]![cboFlightPathList]) AND ((Students.GroupAdvisingSessionID) Is Null))
ORDER BY Students.Major, Students.UpdateGroupAdvisingApt;
Usually an additional filter is manually applied using a list attribute (e.g. [Major]) changing form’s Order By property to (e.g Forms!(StudentsByFlightPath].[Major]=”BI”).
Is there a way to only select from the additional filtered list?
Will an Order BY clause select from additional filtered list?