Hello, Scenario:
I have list of policies for different countries. What I have done so far is that I have designed a query for each country which will pull out the policies for that country. The report is bases on this query. However, this way I am creating lot of queries.
What I want to do is design a query (and therefore the report) so that I can pull out the policies for a country by simply selecting a name from a drop down.
Tables and Fields are as below:
Table[Country]
CountryID
CountryName
Table[Policy]
PolicyID
CountryID
PolicyDetails
Could you please advise if this is possible and if yes, how to achieve this?
Thanks,
SG
13 1373
Yes, that is quite easy.
You should design your report as you normally would, except you do not apply a filter on the country ID. Then you pass(and apply) the filter when you open the report.
Lets imagine you have a combobox in which you have selected your country, lets call it cmb_SelectCountry. You can now choose to either use the AfterUpdate event or make a button with code like so: - Private Sub btn_PrintReport()
-
If IsNull(Me.cmb_SelectCountry) then
-
Msgbox "No country selected"
-
Exit Sub
-
End If
-
-
docmd.OpenReport "rep_MyReportName",acViewPreview,,"ID_Country=" & me.cmb_SelectCountry,acDialog
-
End Sub
Thanks SmileyCoder.
Sorry,I am almost zero in VB coding :-(.
The way I am doing things are:
Step 1 - I am building the query first using Query Design. In the Criteria field, I am using the Country name for which I want the policies.
Step 2 - After saving the query, I am using Report Wizard based on the saved query to generate the report.
So, I am not using and Combobox at the moment (just using the Criteria in the Query design).
Given my situation, could you please walk me through how do I achive my objective?
Many thanks,
SG
In your query, in field CountryName, in the Criteria row write this: Country ?
Run the query, answer to question, and let me know if this help you.
Cheers
PS: Open the report too
Thanks Mihail for your response. I tried what you suggested.
On hitting the run button, there is no question, it just shows a blank datasheet.
The field in the Criteria changes to [Like "Country ?"] after running the query.
Any further suggestion please.
Hi Mihail,
Just to add, I simply put a "?" in the criteria field and then I see this question box popping up. Now wondering, how do I put some additional text so that it shows in the message box that's popping up?
Many thanks,
SG
OK, got this too.. I inserted this as [Country ?], and now I can see it working :-)
Many thanks for your help Mihail.
Sorry to pepper with more questions.....
I just want to know that the solution that you have suggested above, how does it work when the table has more than 1 field?
For eg, in the table[Country], if there are more fields eg
[CountryID]
[CountryName]
[Region]
[etc..]
If I want to use the filter the information based on [Region] or any other field, will it still work?
Many thanks,
:-) It works for multi fields and multi tables as well, thanks.
The problem that I face is that the entry has to be same as that in the table and if the list is long, then it is not great to have everything in the pop- up.
Is there a way that I can show the available options using a drop down so that it is easier for any user to select and generate the report they want?
Thanks,
Yes it is.
See Smiley's solution.
Many thanks. I can do this but I need little bit of hand holding here to implement Smiley's solution.
Can anyone walk me through the steps that I need to take?
Thanks.
I tried the following as suggested by one of the gurus:
1. Create a blank form and add the Combobox/Dropdown control on it.
2. Follow the Wizard to display the names of the countries for the selection.
3. Create a new query (or modify one of the existing ones) to display all the policy data.
4. For the country criteria, enter a reference to the dropdown control on the form. It should look something like this:
Forms!FormName.ControlName
5. Create a new report (or use the same one based on the query you modified) based on the new query.
6. Add a button on the form and follow the Wizard to "open the report."
To test it, open the form and select a country from the dropdown, then click on the button.
This worked for me !
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Stan |
last post by:
Hello all,
I'm looking for some hints as to how to use the results of a query in
another query. I assume I'm 'thinking' wrong in how to solve this, so
I'm hoping someone can clobber me and send...
|
by: PC Datasheet |
last post by:
A query based on TblEmployee shows TblEmployee in the query window. Is there
a way in design view to change this query to self join T1 and T2 on
EmployeeID or does it have to be typed in in SQL...
|
by: Allen Anderson |
last post by:
Hi,
I'm trying to design contact (names and addresses) tables in an Access
database. Some of the contacts represent vendors, some are board members of
the organization, some are donors, some...
|
by: faceman28208 |
last post by:
Over the past few years I have consulted on six large projects that all
independently arrived at the same moronic design desision: The use of
SQL query classes.
No, I don't mean a class...
|
by: santaferubber |
last post by:
The first query returns me the results from multiple databases, the
second does the same thing except it puts the result into a #temp
table? Could someone please show me an example of this using...
|
by: Stan |
last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can
I run a query of a query datasheet. I want to use more that one
criteria and can not get that query to work. I thought I...
|
by: manjubhashini19583 |
last post by:
Sir,
how to write select query and insert query at the same time. I have one database that db having six field. waiting for your reply.
thanking you
|
by: dbarmer |
last post by:
I have a unix database system that hold three tables, 254, 255, 256, and all are linked together by WO, CUST NO, LOC NO. This is for Unix Program Purposes Only. Duplication here is by design. So...
|
by: robin1983 |
last post by:
HI all, how are you ? i need help from you people. This time my problem is that i m running a query inside another query. But, the result that i got is something not exactly what i want. and one...
|
by: alipark |
last post by:
hi,
I am fairly newb to mysql, so excuse my silly question. I am working on a vbmysql application for a warehouse. Here I am importing an excel sheet to mysql which has weekly status of the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |