Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Grid Function 2

Status
Not open for further replies.

fbicfc

Technical User
Nov 13, 2002
35
GB
Hi,

I have a button on a form that brings up a 'Filter by Form' query form.

The issue I have with this is that the form holds the paramaters of the previous query that was run in the form even once the form has been closed.

I have found the 'Clear Grid' function on the Edit menu but can't find a way of of getting the form to automatically use this command when it opens.

The Docmd.DoMenuItem does not seem to have an option for the 'Clear Grid' command.

Does anyone know of a method I can use to get the 'Clear Grid' command to run, or any other suggestions for clearing the previous query paramaters.

TIA

fbicfc
 
This code will clear the text boxes and combo boxes in a form.

Dim ctrl As Control
For Each ctrl In Me.Controls
With ctrl
Select Case .ControlType
Case acComboBox
ctrl.Value = ""
.Requery
Case acTextBox
ctrl.Value = ""
.Requery
End Select
End With
Next

HTH,
Eric
 
Hi,

Thanks for the quick reply, Unfortunately when I use the above code I get a runtime error '2448' - you can't assign a value to this object!

Any ideas?

I should have said I am using Access 2000.

Cheers
 
Easier method

If you have a button to apply the filter by form

you should have the statement

"DoCmd.RunCommand acCmdFilterByForm"

Then place "DoCmd.RunCommand acCmdClearGrid" underneath

I got this off this forum, fantastic bit of code.
nice and simple and does the job very good.

Regards
Lee James
Data Analyst
 
Nice and simple just the way I am usually described, have a star ;) works a treat.
 
Wow. I'm truly honoured.

And I was only looking for a solution to a problem of mine.

Cheers.

Lee James
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top