A97, NT4.
I've inherited a database from a rather talented software developer and
some of his code scares me ;-)
One of the things I'm trying to understand is his custom "filter by form"
utility.
When the form is loaded, "acCmdFilterByF orm" is executed.
Below is the code from the "On Apply Filter" event of the form. Could
someone please tell me how "ApplyType" (one of the arguments) gets a value
of 1? "ApplyType" isn't referenced anywhere else except for in this code
and no arguments are passed when the form is called.
Many thanks,
Keith.
Private Sub Form_ApplyFilte r(Cancel As Integer, ApplyType As Integer)
' Only apply filter if explicity requested from the Shortcut Menu
'
' We have to update the caller from here because we can't
' Filter by Form from a dialog
On Error GoTo errTrap
' Procedure name
Const cProcedure = "Form_ApplyFilt er"
Dim frm As Form
If libIsFormLoaded (gcFrmProgress) Then
Set frm = Forms(gcFrmProg ress)
If ApplyType = acApplyFilter And libIsFormLoaded (gcFrmProgress)
Then
frm!cmdAdvanced .SetFocus
frm!cboFilter.E nabled = False
frm!txtFilterDe scription.Enabl ed = False
frm!txtFilterDe scription.Locke d = False
frm!shpFilter.V isible = False
frm!cboItem.Row Source = "SELECT ItemID, Description, Area,
Type, SeatOwner, Status, Deleted FROM " & Me.RecordSource _
& " WHERE " & Me.Filter & " ORDER BY ItemID"
' frm!cboItem.Row Source = "SELECT DISTINCT tblItem.ItemID,
tblItem.Descrip tion, tblItem.Area, tblItem.Type, tblItem.SeatOwn er,
tblItem.Status, tblItem.Deleted FROM (tblItem INNER JOIN tblTask ON
tblItem.ItemID = tblTask.ItemID) INNER JOIN qfrmProgress ON tblItem.ItemID
= qfrmProgress.It emID WHERE (((tblTask.OpCo de) Not Like 'B*') AND
((tblTask.Progr ess)<1) AND ((tblTask.Appli cable)=True) AND " & Me.Filter &
") ORDER BY ItemID"
frm!cboItem = frm!cboItem.Ite mData(0)
frm!sfrProgress .LinkMasterFiel ds = "cboItem"
frm!sfrProgress .LinkChildField s = "ItemID"
frm.RefreshItem Details
frm.ControlStat e
' frm.Requery
frm.Filtered = True
ElseIf ApplyType = acCloseFilterWi ndow Then
frm.Filtered = False
End If
Set frm = Nothing
End If
' Save filter (users do not have write access)
gFilter = Me.Filter
' Close form
DoCmd.Close acForm, Me.Name
Exit Sub
I've inherited a database from a rather talented software developer and
some of his code scares me ;-)
One of the things I'm trying to understand is his custom "filter by form"
utility.
When the form is loaded, "acCmdFilterByF orm" is executed.
Below is the code from the "On Apply Filter" event of the form. Could
someone please tell me how "ApplyType" (one of the arguments) gets a value
of 1? "ApplyType" isn't referenced anywhere else except for in this code
and no arguments are passed when the form is called.
Many thanks,
Keith.
Private Sub Form_ApplyFilte r(Cancel As Integer, ApplyType As Integer)
' Only apply filter if explicity requested from the Shortcut Menu
'
' We have to update the caller from here because we can't
' Filter by Form from a dialog
On Error GoTo errTrap
' Procedure name
Const cProcedure = "Form_ApplyFilt er"
Dim frm As Form
If libIsFormLoaded (gcFrmProgress) Then
Set frm = Forms(gcFrmProg ress)
If ApplyType = acApplyFilter And libIsFormLoaded (gcFrmProgress)
Then
frm!cmdAdvanced .SetFocus
frm!cboFilter.E nabled = False
frm!txtFilterDe scription.Enabl ed = False
frm!txtFilterDe scription.Locke d = False
frm!shpFilter.V isible = False
frm!cboItem.Row Source = "SELECT ItemID, Description, Area,
Type, SeatOwner, Status, Deleted FROM " & Me.RecordSource _
& " WHERE " & Me.Filter & " ORDER BY ItemID"
' frm!cboItem.Row Source = "SELECT DISTINCT tblItem.ItemID,
tblItem.Descrip tion, tblItem.Area, tblItem.Type, tblItem.SeatOwn er,
tblItem.Status, tblItem.Deleted FROM (tblItem INNER JOIN tblTask ON
tblItem.ItemID = tblTask.ItemID) INNER JOIN qfrmProgress ON tblItem.ItemID
= qfrmProgress.It emID WHERE (((tblTask.OpCo de) Not Like 'B*') AND
((tblTask.Progr ess)<1) AND ((tblTask.Appli cable)=True) AND " & Me.Filter &
") ORDER BY ItemID"
frm!cboItem = frm!cboItem.Ite mData(0)
frm!sfrProgress .LinkMasterFiel ds = "cboItem"
frm!sfrProgress .LinkChildField s = "ItemID"
frm.RefreshItem Details
frm.ControlStat e
' frm.Requery
frm.Filtered = True
ElseIf ApplyType = acCloseFilterWi ndow Then
frm.Filtered = False
End If
Set frm = Nothing
End If
' Save filter (users do not have write access)
gFilter = Me.Filter
' Close form
DoCmd.Close acForm, Me.Name
Exit Sub
Comment