473,952 Members | 17,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filter report based on combobox seletion in forum

18 New Member
what i want to do is basically have form where my selection in the combox make the diffrence with what the form reports.

this is what the underlying informaion is....

software is access 2007
i got a table where there is name of contacts and with status of away or available
then i got form...which has combo box with options AWAY and AVAILABLE
and also a command button.
then my report has selected colums from the contacts table.

so now what i need to know is basically what is the code to put in "on click" in command button that would cause the filteration to happen based on the selection in th combo box.
Aug 22 '07 #1
6 6029
Rabbit
12,516 Recognized Expert Moderator MVP
what i want to do is basically have form where my selection in the combox make the diffrence with what the form reports.

this is what the underlying informaion is....

software is access 2007
i got a table where there is name of contacts and with status of away or available
then i got form...which has combo box with options AWAY and AVAILABLE
and also a command button.
then my report has selected colums from the contacts table.

so now what i need to know is basically what is the code to put in "on click" in command button that would cause the filteration to happen based on the selection in th combo box.
The DoCmd.OpenRepor t function has a filter parameter.
Aug 22 '07 #2
pouj
18 New Member
The DoCmd.OpenRepor t function has a filter parameter.

can you explain to me how i do that?
Aug 22 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
From the help files:

OpenForm Method
The OpenForm method carries out the OpenForm action in Visual Basic.

DoCmd.OpenForm( FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)

FormName Required Variant. A string expression that's the valid name of a form in the current database. If you execute Visual Basic code containing the OpenForm method in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database.

View Optional AcFormView.

AcFormView can be one of these AcFormView constants.
acDesign
acFormDS
acFormPivotChar t
acFormPivotTabl e
acNormal default. Opens the form in Form view.
acPreview
If you leave this argument blank, the default constant (acNormal) is assumed.


FilterName Optional Variant. A string expression that's the valid name of a query in the current database.

WhereCondition Optional Variant. A string expression that's a valid SQL WHERE clause without the word WHERE.

DataMode Optional AcFormOpenDataM ode. The data entry mode for the form. This applies only to forms opened in Form view or Datasheet view

AcFormOpenDataM ode can be one of these AcFormOpenDataM ode constants.
acFormAdd The user can add new records but can't edit existing records.
acFormEdit The user can edit existing records and add new records.
acFormPropertyS ettings default
acFormReadOnly The user can only view records.
If you leave this argument blank (the default constant, acFormPropertyS ettings, is assumed), Microsoft Access opens the form in the data mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.


WindowMode Optional AcWindowMode. The window mode in which the form opens.

AcWindowMode can be one of these AcWindowMode constants.
acDialog The form's Modal and PopUp properties are set to Yes.
acHidden The form is hidden.
acIcon The form opens minimized in the Windows taskbar.
acWindowNormal default The form is in the mode set by its properties
If you leave this argument blank, the default constant
(acWindowNormal ) is assumed.


OpenArgs Optional Variant. A string expression. This expression is used to set the form's OpenArgs property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions.

For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can specify the client name with the openargs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name.

This argument is available only in Visual Basic.

Remarks
For more information on how the action and its arguments work, see the action topic.

The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).

You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.

Example
The following example opens the Employees form in Form view and displays only records with King in the LastName field. The displayed records can be edited, and new records can be added.

DoCmd.OpenForm "Employees" , , ,"LastName = 'King'"
Aug 23 '07 #4
Nhoung Ar
13 New Member
what i want to do is basically have form where my selection in the combox make the diffrence with what the form reports.

this is what the underlying informaion is....

software is access 2007
i got a table where there is name of contacts and with status of away or available
then i got form...which has combo box with options AWAY and AVAILABLE
and also a command button.
then my report has selected colums from the contacts table.

so now what i need to know is basically what is the code to put in "on click" in command button that would cause the filteration to happen based on the selection in th combo box.

Hi! pouj,

If I understand well what you mean that, after you select the option on your from and click command button your report will show all records which match to your selection.

1. Create the query (queryName) from your table, put the criteria under field status:

Like [Forms]![formName]![comboName]

2. Create report from this query.

3. Your form (formName) contains field combo (comboName), which you can either selecting from fields status (you table) or from value list (AWAY and AVAILABLE) or you can also type ahead.

4. In the event on click of your command button put this:

Docmd.OpenRepor t "reportName ", acPreview

That all, this works fine for mine so far.
Aug 23 '07 #5
pouj
18 New Member
Hi! pouj,

If I understand well what you mean that, after you select the option on your from and click command button your report will show all records which match to your selection.

1. Create the query (queryName) from your table, put the criteria under field status:

Like [Forms]![formName]![comboName]

2. Create report from this query.

3. Your form (formName) contains field combo (comboName), which you can either selecting from fields status (you table) or from value list (AWAY and AVAILABLE) or you can also type ahead.

4. In the event on click of your command button put this:

Docmd.OpenRepor t "reportName ", acPreview

That all, this works fine for mine so far.

okay but how would the comand button know whats the selection in the combo box? and would this work with ore then 1 combo box? cause i might need to run up to 10 different filters.
Aug 23 '07 #6
Nhoung Ar
13 New Member
okay but how would the comand button know whats the selection in the combo box? and would this work with ore then 1 combo box? cause i might need to run up to 10 different filters.

OK, it works like this:

1. After you filled out all your selection/combo box (for example 10 combo) in your form and click the command button. (This form contains only 10 combo boxes and command button).

2. It will then try to open your report, which took the record from the query, which had a criteria and

3. This criteria will match to the value in your combo on your form, then it previews the report.

Try this and get back to the forum if you are still unsuccess.
Aug 24 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
12010
by: Matt | last post by:
Hi everyone, still pretty new to MySQL. I was wondering if there is a way to automatically filter records based on a mysql userlogin name?? I have serveral databases that I want to combine in order to manage the databases more efficiently. - I'm currently using MySQL 4.1.12 and I'm currently testing 5.0.14 - I have a databases for each user account. - Each database has the same schema and entity relation model.
3
6626
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
2
7280
by: Rosy | last post by:
I am attempting to use the following code to print a report based on the current record in the form. Users bring up the record with a parameter box and then can make changes to the sub-form on the main form (main form is locked). I use this same code for another form/report and it works. The only difference is the parameter. The one that works opens to all records and then the user uses the filter by form. I don't want them to do that...
5
2809
by: favor08 | last post by:
have a mainform called PendingsMain and a subform called PendingsSub. You can filter the subform by different filters and this works fine. i want to create a report that will print out the results of the users filters or print everything if there is no filters submitted within the form. Any suggestions
94
7002
by: mlcampeau | last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries. MY - JobVacancyJobs SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum, Grade.Midpoint, Grade.Maximum, Job.EEOCategoryCode, EEOCategory.Desc, Job.EEOSubCategoryCode, EEOSubCategory.Desc FROM Grade RIGHT JOIN (EEOSubCategory RIGHT JOIN (EEOCategory RIGHT JOIN Job ON EEOCategory.Code = Job.EEOCategoryCode) ON...
12
2767
by: HowHow | last post by:
I need to create a few reports using one query and I wish to do the program filter from the buttons in a form. I had created a query named q_ClientsHvServices and a report based on that query named Rpt_ClientsHvService. In the main form, I created few buttons to view clients from different progrom. When I click on a button named "HACC", the report should select all the clients that have services under PROGRAM starting with HA (and all HA*). When...
11
20194
by: billa856 | last post by:
Hi, I have project in MS Access.In that I have one form in which there is one combobox .I want to know when I select an item from that combobox and click on submit button then it should open a report which filter data from table.So i only want specific data from table in report based on selection of item from combobox in a form. Can anyone help? Thanks.
7
2201
by: Xaysana12345 | last post by:
Hello there, I have created number of Buttons on unbound form to filter the report based on a pivot query called filters. Report named AnnualReport-ProjectFilter. What I would like to do is that: 1. When I click a button named btnCT then it should search in a Pivot query where the field named ProjectName = CT then views only all the records related to CT Project in the Report. Now when I click a button name btnCP, it should exhibit...
0
1024
by: munkee | last post by:
Hi all, This would normally be quite simple however for some reason I can not getting working. My code to open my report filtered to a primary key is as follows: Case "Full record" DoCmd.Close acForm, "frmHowToReport" DoCmd.OpenReport "rptPrintLog", acViewPreview, , "=" & Forms!!.Form! DoCmd.Maximize
0
10183
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10000
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11612
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11210
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7453
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4971
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.