Using Filters Or RecordSources

PC User

Registered User.
Local time
Today, 12:11
Joined
Jul 28, 2002
Messages
193
I have a continuous subform that has changing conditions of whether it will be controled by a date range or not; also whether all its checkboxes are selected or not. This amounts to a multitude of possible combinations.

1. All checkboxes checked with no date range
2. All checkboxes checked with a date range
3. No checkboxes checked with no date range
4. No checkboxes checked with a date range.

The subform shows up like a list box with column headings and I also have sort buttons on the column headings. This requires the changing of conditions also.

1. Sort assending with no date range
2. Sort decending with no date range
3. Sort assending with a date range
4. Sort decending with a date range.

As you might guess the recordsource or filter can be constantly changing with the users mouse click. I don't know which would be easier (using filters or recordsources), because I can't get either to work. Below are my two attempts. I use option toggle buttons to indicate whether or not to filter (change recordsource) for the update query.

Using filters
====================================
Private Sub btnSelectAll_Click()
Dim db As Database
Dim strSQL As String
Dim Frm As Form
Dim sfN As Form 'Program Notification SubForm
Set Frm = Forms!frmMainEntry.Form
Set sfN = Frm.[fctlNotifications].Form
strSQL = "qupdNotificationSelectionYes"
If NotificationFilter = 1 Then
sfN.Filter = ""
sfN.FilterOn = False
Else
sfN.Filter = "tblMainData.DueDate = #" & "Between [Forms]![frmMainEntry]![BeginningDate] And [Forms]![frmMainEntry]![EndingDate] & #"
sfN.FilterOn = True
End If
CurrentDb.Execute strSQL, dbFailOnError
sfN.Refresh
Form.Refresh
Me.txtCountSelected.SetFocus
Me.txtTotalRecords.SetFocus
End Sub
====================================
====================================


Using recordsources
====================================
Private Sub btnSelectAll_Click() 'Select all checkboxes meeting criteria
Dim db As Database
Dim strSQL As String
Dim Frm As Form
Dim sfN As Form 'Program Notification SubForm
Set Frm = Forms!frmMainEntry.Form
Set sfN = Frm.[fctlNotifications].Form
If NotificationFilter = 1 Then
strSQL = "qupdNotificationSelectionYes "
CurrentDb.Execute strSQL, dbFailOnError
Else
Call CheckNotificationDates
strSQL = "qupdNotificationSelectionYesDates "
sfN.CurrentDb.Execute strSQL, dbFailOnError
End If
sfN.Refresh
Form.Refresh
Me.txtCountSelected.SetFocus
Me.txtTotalRecords.SetFocus
End Sub
====================================
Also, how do I about the update query? My understanding is that an update query should not be assigned to a form's recordsource or its filter. What should I do about the select all and the select none update queries? They still need to be developed with the date range criteria. Is there a way to ensure that the results from the recordsource or filter calculation is synchronized with the update queries?

I hope someone can help me with this. In the filter, I get an error with the criteria. In the recordsource, I get an error in the execution of the currentdb. This is a very busy subform.

Thanks,
pc
 
Last edited:

Users who are viewing this thread

Back
Top Bottom