Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Need to add code to code filtering form...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary A Perez - 30 Nov 2005 16:29 GMT
The following code was built with the command wizard & works great, however,
I need to add addtional code to filter with more content.  Currently, when
the command button is clicked, it opens the form based on the Plan and
Product chosen.   The user will also have to choose the location, effective
and term dates as well to drill down to the form they wish to view.  How do I
add code to include these items so when the user clicks the command button,
not only will the form open to the correct plan and product, but to the
matching location, effective and term dates as well.  
Thank you for your help.

Private Sub cmdClickforContractInformation_Click()
On Error GoTo Err_cmdClickforContractInformation_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "frmContractRates-Specifications"
   
   stLinkCriteria = "[ProductId]=" & Me![cmbProduct]
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation_Clic:
   Exit Sub

Err_cmdClickforContractInformation_Click:
   MsgBox Err.Description
   Resume Exit_cmdClickforContractInformation_Clic
   
End Sub
fredg - 30 Nov 2005 17:16 GMT
> The following code was built with the command wizard & works great, however,
> I need to add addtional code to filter with more content.  Currently, when
[quoted text clipped - 25 lines]
>    
> End Sub

Generic code would be something like this (all on one line, or on
several lines if you use the line continuation characters):
stLinkCriteria = "[ProductId]=" & Me![cmbProduct] & " AND [ATextField]
= '" & Me![OtherControl] & "' AND  [ADateField] = #" &
Me![DateControlOnForm] & "#"

You would have to substitute your actual field and control names.

Please read VBA Help on
Restrict + Restrict Data to a Subset of Records + Multiple Fields in
Criteria Expressions

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Mary A Perez - 30 Nov 2005 23:25 GMT
Well, I have decided to add the location to the product table, so that the
command button code I have working continues to pick the correct form.
Now my only dilema left is that there are multiple forms to open/filter for
each plan and product because of their different effective dates.  Now, the
only location of these effective dates is in the form to open, there is no
separate table for just the effective dates.  (I decided that the term date
was not a necessity for the user to choose)
So, how do I make the effective date part of what is needed for the user to
choose before clicking the command button that will take them to the correct
form?
Thanks again for all your help.

> > The following code was built with the command wizard & works great, however,
> > I need to add addtional code to filter with more content.  Currently, when
[quoted text clipped - 37 lines]
> Restrict + Restrict Data to a Subset of Records + Multiple Fields in
> Criteria Expressions
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.