Hi, Bob.
Detecting filters and filter events on a form can be tricky. Try the
following syntax in your form's OnCurrent event:
'***** Begin Code *****
Private Sub Form_Current( )
On Error GoTo ErrHandler
If (Me.FilterOn) Then
If (Nz(Me!ZipCode.Value, "") = "") Then
MsgBox "Please enter a value in the ZipCode field."
End If
End If
Exit Sub
ErrHandler:
MsgBox "Error in Form_Current( ) in" & vbCrLf & Me.Name & _
" form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
'***** End Code *****
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
"Salad" <oi*@vinegar.com> wrote in message
news:wf***************@newsread3.news.pas.earthlin k.net...
Bob Hynes wrote:
Thanks for the comment but I've tried the 'OnApplyFilter' event which
does not work in my case. I should have added to my note that I'm
using a Query-By-Form form and the 'OnApplyFilter' event does not
reconize that I have selected a value in any field in the detail
section which lead me to the assumption that the 'OnApplyFilter
happens before the form reconizes it has criteria in the detail
section.
bobh.
Salad <oi*@vinegar.com> wrote in message
news:<J1*************@newsread3.news.pas.earthlink .net>...Bob Hynes wrote:
Hi All,
When a user(s) click on the 'Apply Filter' toolbar button I want to
run some code before the 'apply filter' kicks off. That code is to
check to be sure that the user has selected a value in a perticular
field and if no value was selected then display a msgbox and then
execute the 'apply filter' else just execute the 'apply filter' so, i
think my question is;
how do I detect(vba code)when a standard toolbar button is clicked in
Access97?
thanks
bobh.
I haven't tested it but open the form's property sheet, select Events,
and see if the OnFilter or OnApplyFilter events will help you out.
Well, maybe you can create a menu option that calls a function. Call it
ApplyFilter. Then your function can set values and perform actions.
See the Docmd.Runcommand in help for a list of constants for applying
the filter.