Filter button

H

HOW1

I have the following code programmed into a command button to allow the user
to filter records. After the filter has been applied the user closes the form
and clicks on the same command button to apply another filter. Can the form
be programmed so that the form holds the data entered in the previous search/
filter to prevent the user having to re-enter similar data again?

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SEARCH"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
DoCmd.RunCommand acCmdFilterByForm
DoCmd.RunCommand acCmdClearGrid

Thanks in advance.
 
O

OldPro

I have the following code programmed into a command button to allow the user
to filter records. After the filter has been applied the user closes the form
and clicks on the same command button to apply another filter. Can the form
be programmed so that the form holds the data entered in the previous search/
filter to prevent the user having to re-enter similar data again?

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SEARCH"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
DoCmd.RunCommand acCmdFilterByForm
DoCmd.RunCommand acCmdClearGrid

Thanks in advance.

I can see two ways to do this; 1) don't close the form, just turn it
invisible. Only close it when you close the calling form. Or, 2)
handle the reading and displaying of the data with code. This way you
could pass the key field to the search form through the OpenArgs
property, where it would automatically search for and load this record
first (if the OpenArgs is not NULL or blank).
 
H

HOW1

I have removed the cleargrid code and it seems to hold the data entered by
the user in the previous search. Can you advise if there is a clear grid
command that I can add as a button to my customised toolbar so that the user
can clear the grid when required?

Thanks again.
 
O

OldPro

I have removed the cleargrid code and it seems to hold the data entered by
the user in the previous search. Can you advise if there is a clear grid
command that I can add as a button to my customised toolbar so that the user
can clear the grid when required?
I haven't tried it, but It should still work in a button on the form
that you want to clear, or in a menu item.
 

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

Similar Threads

Screen blanks when record does not exist 2
Remove filter 4
Criteria when opening form 1
cannot filter continuous form data 2
can't find form 4
If Statements 4
Inserting data in forms 2
stLinkCriteria 3

Top