Update Query and Filters

Charles Carter

New member
Local time
Today, 15:38
Joined
Sep 30, 2002
Messages
5
Have an update query that changes the Checkmark box to all on(yes) or all off(no). Those queries are assigned to buttons on a Datasheet Form.

It works but what I would like to do is limit the query update action to the filtered set of records.

Example: The main table has 4500 records, then I use a filter button to filter those 4500 records to 81. Then, I'd like the 'Select All' or 'Unselect All' query to run and apply only to those 81 records.

Currently it selects or unselects all 4500 records in the table.

Code:

Query assigned to 'Unselect All' button where .Change is a Checkbox"

UPDATE GlobalChange SET GlobalChange.Change = No
WHERE (((GlobalChange.Change)=-1));

Query assigned to "Select All' button where .Chage is a Checkbox:

UPDATE GlobalChange SET GlobalChange.Change = Yes
WHERE (((GlobalChange.Change)=0));

Code assigned to Fillter by selection button:

Private Sub Command15_Click()
On Error GoTo ErrHandler
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2046 'Filter not available at moment
MsgBox "Command not available"
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
End Select
End Sub

I've almost got this form to work the way I want, just need to apply the actions to the filtered set of records only.

Any thoughts.

Thanks,
Charles
 

Users who are viewing this thread

Back
Top Bottom