473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Code to determine query

135 100+
Hello,

I have two forms (ENGLISH AND FRENCH) each with buttons that open reports in the language of the form. The only difference in the reports is that their query returns data from different fields.

In this sense i have.

TblCommodity Names with
commodityID
commodityenglish
commodityfrench

What code do i need to redirect the query taking in consideration the name of the form where the user opens the reports???

Thnks.
Oct 11 '07 #1
5 1169
nico5038
3,080 Expert 2GB
Better to create a French and English query and use that for the forms.
Creating a query depending on the name of a form is "tricky" as a change of name ruins the query...

Nic;o)
Oct 11 '07 #2
Gilberto
135 100+
Better to create a French and English query and use that for the forms.
Creating a query depending on the name of a form is "tricky" as a change of name ruins the query...

Nic;o)
Thanks Nico, that sounds better, can you elaborate a bit more. I thought that queries were just for reports.

Gilberto
Oct 12 '07 #3
nico5038
3,080 Expert 2GB
Queries and tables are more or less "the same" as both extract data from the database. Tables are "elementary" and queries add the possibility to extract data (SELECT) from multiple tables, but also allow the selection of a subset of fields from one table.
Both reports and forms can be linked ("bound") to any table or query to extract their data.

Nic;o)
Oct 12 '07 #4
Gilberto
135 100+
Thnks nico. I just still dont understand how to define the query so that on user "response" it opens the adequate report (ENGLISH report or FRENCH report).

This is my exact situation. I have a FRENCH report whose query reads:
Expand|Select|Wrap|Line Numbers
  1. SELECT Engineering.Commodity, 
  2. nz(Sum(IIf([Engineering].[Seating]="front",(Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS FRONT,
  3. nz(Sum(IIf([Engineering].[Seating]="rear",( Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS REAR,
  4. nz(Sum((Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+Engineering![Level 1 Rear])),0) AS MIX
  5. FROM Engineering
  6. WHERE Engineering.Variant1=-1
  7. GROUP BY Engineering.Commodity
  8. ORDER BY Engineering.Commodity
  9. UNION SELECT "Total" AS Commodity, 
  10. nz(Sum(IIf([Engineering].[Seating]="front", (Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS FRONT,
  11. nz(Sum(IIf([Engineering].[Seating]="rear", (Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS REAR,
  12. nz(Sum((Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+Engineering![Level 1 Rear])),0) AS MIX
  13. FROM Engineering
  14. WHERE Engineering.Variant1=-1;
and a modyfied query that brings ENGLISH names instead of french ones like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT [commodity name].CommodityEnglish,
  2. nz(Sum(IIf([Engineering].[Seating]="front",(Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS FRONT,
  3. nz(Sum(IIf([Engineering].[Seating]="rear",( Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS REAR,
  4. nz(Sum((Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+Engineering![Level 1 Rear])),0) AS MIX
  5. FROM Engineering INNER JOIN [COMMODITY NAME] ON (Engineering.Commodity = [COMMODITY NAME].Commodity )  
  6. WHERE Engineering.Variant1=-1
  7. GROUP BY [commodity name].CommodityEnglish
  8. ORDER BY [commodity name].CommodityEnglish
  9. UNION SELECT "Total" AS CommodityEnglish,
  10. nz(Sum(IIf([Engineering].[Seating]="front", (Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS FRONT,
  11. nz(Sum(IIf([Engineering].[Seating]="rear", (Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+ Engineering![Level 1 Rear]),0)),0) AS REAR,
  12. nz(Sum((Engineering![Weight]/1000)* (Engineering![Level 1 Driver]+Engineering![Level 1 Passenger]+Engineering![Level 1 Rear])),0) AS MIX
  13. FROM Engineering
  14. WHERE Engineering.Variant1=-1;
All i need is that without having to create duplicate REPORTS, someway the user can indicate if he wants the report in ENGLISH (which will follow the second query) or in FRENCH (which will follow the first query).

How can i do this???

Thanks again,
Gilberto
Oct 15 '07 #5
nico5038
3,080 Expert 2GB
You'll need to store the needed language somewhere.
Let's assume you've created a form to start the report named "frmReports".
Now place a combobox named "cmbLanguage" on the form holding "English" and "Francais".

Now use your second query from the revious statement and change the first field like:
Expand|Select|Wrap|Line Numbers
  1. SELECT IIF(Forms!frmReports!cmbLanguage="English",[commodity name].CommodityEnglish,Engineering.Commodity), .....
  2.  
Getting the idea ?

Nic;o)
Oct 15 '07 #6

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

Similar topics

1
by: John Sway | last post by:
I'm writing a web-based "Query analyser" tool for our company intranet. It allows a user to type any SQL statement in a form, and execute it over the Web. The SQL can be a query that returns...
3
by: Shahid Juma | last post by:
Hello All, This may be a trivial question, but I was wondering how can you determine if a value contains an Integer or Float. I know there is a function called IsNumeric, however you can't...
5
by: Hennie de Nooijer | last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem clear to you. SITUATION I'm building A SLA Query for a customer. This customer has an awkward way to determine the SLA results...
4
by: laurenq uantrell | last post by:
I am trying to determine which of three stored procedure designs are fastest in the Query Analyzer: One query is a straight SELECT query with all desired rows and a dozen (tblName.RowName =...
2
by: Mary | last post by:
I am trying to develop a query which will determine the average costs using a rolling average of the past 12 months of data. In other words, if I entered the Ship Month of January and the Ship...
4
by: Ron St-Pierre | last post by:
I am using postgres 7.3.4 and need to be able to determine which database a query is being run in (from a script). pg_database lists databases but doesn't tell me which one is currently active. Is...
1
by: Tony Ciconte | last post by:
I have a table of customers who may have purchased numerous types of products. Finding out who purchased what is easy. However, what I need to determine is which customer has purchased ONLY one or...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
2
by: RoomfulExpress | last post by:
The only problem I'm having with this code is when there are no values returned for the query, it is still allowing you to see and click the 'Next>>'. It disappears when there is at least one return...
3
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
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...
0
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,...
0
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...
0
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,...
0
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...

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.