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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to apply filter on form

Status
Not open for further replies.

srast

MIS
Nov 11, 2002
42
US
Hello All.
I have a form which displays all customer orders. What I am trying to do is allow a user to enter a starting date and an ending date on another form, and the open my customer orders form based on that range of dates.
My code is as follows:
Dim filterStr As String
Dim formToOpen As String

Private Sub MakeFilter_Click()
formToOpen = "DE Customer Orders"
filterStr = "[ShipDate] Between #" & [Forms]![View Cust Orders by Ship Date]![starting]
filterStr = filterStr + "# And #" & [Forms]![View Cust Orders by Ship Date]![ending] & "#"
Debug.Print filterStr
DoCmd.OpenForm formToOpen, acNormal, filterStr

So far, it simply opens the form, ithout applying the filter.
Any ideas would be greatly appreciated!
Steve
 
Not sure what's going on, but here are a couple of things to play with:

1) I'm SURE this is not it, but you use + instead of & in one instance. I would change this to &.

2) What is the flow of code here? What's calling what, and in what event? Hopefully this is being called by a button on that other form. Is that the case?

3) Are you sure the dates you've chose would filter out any records?

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Jeremy;
2) That's right. The user opens one form to enter the dates in two textboxes. The user presses a button, which has the code I showed you.
3) Yes. The dates absolutely filter out some records.

Let me elaborate a little more.
The Customer Orders form is a form/subform with the basic order info on the main form, and the order details on the subform. One of the items on the main form is the ship date.
I need to only display orders where the ship dates fall in the range the user enters.

I also change the '+' to '&' and that wasn't the problem as you said.
Any other clues?
Thanks.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top