Opening a form and filtering it at the same time

jh2593

Registered User.
Local time
Today, 03:44
Joined
Feb 23, 2011
Messages
11
I am trying to use a button on a form that will open another form (Contract Management Database) and filter it by the company name at the same time. I am attaching the zipped file.

Directions to understand what I am talking about:
Open the file
Click on the form labeled Home
Then click on the Broadcast button
It then takes you to another form
The far left button (haven't labeled for security purposes) I would like to open the form labeled Contact List and filter it by company name.

Essentially, the botton's that aren't labeled will have the company names on them so we are able to navigate through clients easily. If anyone has a solution on how to do this that would be greatly appreciated!!!
 

Attachments

You can use something like the following to Filter your form;
Code:
    Dim strFilter As String
    
    strFilter = "[FieldNameToFilterOn] = [COLOR="Red"] '[/COLOR]YourFilterString[COLOR="Red"]'[/COLOR] " [COLOR="SeaGreen"]' To hard code your filter term[/COLOR]
    strFilter = "[FieldNameToSearch] = '" & Me.FomControlThatHoldsFilterTerm & "'" [COLOR="SeaGreen"]'Use this if the filter term is held in a control on your form[/COLOR]

    Me.Filter = strFilter
    Me.FilterOn = True
To return the form to an Unfiltered state use;
Code:
Me.FilterOn = False
 
Last edited:
I appreciate your timely response, I am not quite sure where I would put your codes. I also am not quite sure how to replace my info with your info. If you can elaborate a little more that would be very helpful. Thanks!!:)
 
Perhaps the attached sample will make it a little easier to understand.

The top section of the form filters the form via a combo box which returns a numeric value, whilst the bottom section filters the form via a series of hard coded buttons that filter on a Text filed.
 

Attachments

:)Ok, I understand now. But I don't think it is quite what I am looking for. Did you have a chance to take a look at my attachment? I am wanting to have a button from a form to open another from and filter it in a table (in datasheet view) By one of the column titles..
 
Sorry I can't open you DB as I currently only have access to Access '03.

However all you need to do is pass the Filter Term in the Where Condition of the DoCdm.OpenForm command, which might look something like;
Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FormNameToOpen"
    stLinkCriteria = "[FieldName]=" & Me![ControlName][COLOR="SeaGreen"] 'ControlName would be the name of the control that hold the filter term you want to apply[/COLOR]

    DoCmd.OpenForm stDocName, , , stLinkCriteria

Once again;
Code:
Me.FilterOn = False
will remove the filter from the form.
 

Users who are viewing this thread

Back
Top Bottom