Clear Grid

G

Guest

Hi
I'm trying to create a customized toolbar for searching. It currently
contains two options.
1) Apply Filter
2) Switch off filter

I want to add a third option to Clear Grid but I cannot find it in anywhere
in the Commands tab when I select Customize.

Can anyone help please???
 
G

Guest

I want to add a third option to Clear Grid but I cannot find it in anywhere
in the Commands tab when I select Customize.

This command is only available via VBA code. That's why it's normally
applied in a form event or control event, such as when a button is clicked to
initiate Filter-by-form.

Right-click on the menu bar and select Customize... from the pop-up menu.
Select the "Commands" tab and select the "Custom" item in the right-hand
pane. Drag this item to the custom menu bar. Right-click on the new
"Custom" item and select "Properties" on the pop-up menu to open the <Custom
CommandBar> Control Properties dialog window. Change the Caption Property to
Clear Grid. Select the On Action Property and type:

=clearGrid()

Select the "Close" button to save these changes. Select the "Close" button
to close the Customize dialog window.

Create a new standard module and place the following code in it:

Public Function clearGrid() As Boolean

On Error GoTo ErrHandler

RunCommand acCmdClearGrid

Exit Function

ErrHandler:

MsgBox "Error in clearGrid( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Function

Save the module and compile the code. (Don't name the new module the same
name as any procedure that the module contains.)

Open a form in Form View and apply the Filter-by-form feature. Make any
selection on the form, then select the new "Clear Grid" button on the custom
command bar. The grid has now been cleared.

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.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

Muchos Gracias :)

'69 Camaro said:
This command is only available via VBA code. That's why it's normally
applied in a form event or control event, such as when a button is clicked to
initiate Filter-by-form.

Right-click on the menu bar and select Customize... from the pop-up menu.
Select the "Commands" tab and select the "Custom" item in the right-hand
pane. Drag this item to the custom menu bar. Right-click on the new
"Custom" item and select "Properties" on the pop-up menu to open the <Custom
CommandBar> Control Properties dialog window. Change the Caption Property to
Clear Grid. Select the On Action Property and type:

=clearGrid()

Select the "Close" button to save these changes. Select the "Close" button
to close the Customize dialog window.

Create a new standard module and place the following code in it:

Public Function clearGrid() As Boolean

On Error GoTo ErrHandler

RunCommand acCmdClearGrid

Exit Function

ErrHandler:

MsgBox "Error in clearGrid( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Function

Save the module and compile the code. (Don't name the new module the same
name as any procedure that the module contains.)

Open a form in Form View and apply the Filter-by-form feature. Make any
selection on the form, then select the new "Clear Grid" button on the custom
command bar. The grid has now been cleared.

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.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top