Good day. This is a follow-up to a previous question. I have a form with 2 comboboxes where the 2nd one depends on the value in the 1st one. I have the code to show the drop down list in the 2nd combobox but I am unable to select anything but the first entry.
Table 1: name - Supply_Sources, fields - Source_ID(pk), SupplySourceName
Table 2: name - Warehouse_Locations, fields - WLocation_ID(pk), Location_Name
Table 3 (junction): name - SupplySource_WarehouseLocation, fields - Supply_Source_ID(pk), Location_In_ID(pk)
On my form 'frmInventoryReceivedInput' I have cboSupplySource and cboWLocation. I populate cboSupplySource with
SELECT [Supply_Sources].[Source_ID], [Supply_Sources].[SupplySourceName]
FROM Supply_Sources;
The SQL for cboWLocation is:
SELECT SupplySource_WarehouseLocation.Supply_Source_ID,
Warehouse_Locations.Location_Name FROM Warehouse_Locations
INNER JOIN (Supply_Sources INNER JOIN SupplySource_WarehouseLocation
ON Supply_Sources.Source_ID = SupplySource_WarehouseLocation.Supply_Source_ID)
ON Warehouse_Locations.WLocation_ID = SupplySource_WarehouseLocation.Location_In_ID
WHERE ((( SupplySource_WarehouseLocation.Supply_Source_ID)=
[forms]![frmInventoryReceivedInput]![cboSupplySource]));
There are 3 options for me in the cboWLocation drop down list (based on cboSupplySource). However, it doesn't matter which one I choose, it defaults to the first one. What do I need to do to be able to choose the other options?
I recreated it and it works OK, the only thing I did differently was create a query with the SQL:
SELECT
SupplySource_WarehouseLocation.Supply_Source_ID, Warehouse_Locations.Location_Name
FROM
Warehouse_Locations INNER JOIN
(Supply_Sources INNER JOIN
SupplySource_WarehouseLocation ON
Supply_Sources.Source_ID = SupplySource_WarehouseLocation.Supply_Source_ID) ON
Warehouse_Locations.WLocation_ID = SupplySource_WarehouseLocation.Location_In_ID
WHERE
(((SupplySource_WarehouseLocation.Supply_Source_ID)=
[forms]![frmInventoryReceivedInput]![cboSupplySource]));
so I could check that part separately from the UI.
For cboWLocation, I have column widths 0";1", rowSource qry_cbo2, and bound column 2. Try changing your bound column from 1 to 2 and see if that helps.
-Beth
Related
I'm using Oracle apex, and i have 2 select list components that get the elements from the same table. i want build a currency converter, and the list of currency are "divisas"
My problem is: i want validate that when on one select component, one value is selected, the other component doesn't contain that element from select list 1. And vice verse
Also when on select 1 is null on the select 2 must show all result from the table, and vice verse.
I start with this query, but i can't do it works
select *
from divisas
where EN_APP = 'S'
and (
case when :P12_DIVISA is not null then (cod_divi <> :P12_DIVISA) else EN_APP = 'S' end
)
;
can somebody help me?
There's the Cascading List of Values property for Select List items. However, as you want to handle both items at the same time, you'll enter circular reference & dead loop so it won't just work.
Here's an option which does what you wanted; see if it helps:
create two items, e.g. P59_CURR_1 and P59_CURR_2 (for two currencies)
their type is Select List item
Page action on selection = "Redirect and set value"
SQL query looks like this (for P59_CURR_1)
select cod_divi d, cod_divi r
from divisas
where cod_divi <> nvl(:P59_CURR_2, 'X') -- would be `:P59_CURR_1` for another item
order by cod_divi
don't set cascading list of values parent item!
That's it; run the page and see how it behaves. Looks OK to me on apex.oracle.com's Apex 20.1 version.
I currently have 2 views that house some data.
View1: includes patientsPID and their billing/invoice information (high-level)
View2: includes patientsCID and their respective line items for their billing invoice information (granularity of View1)
I am trying to run a query where I will be able to validate some data. E.g. -> I want to see patientsPID = 1 and see the total amount paid and join it to View2 to see in more details on the invoice.
expected results
Thank you.
You need to join View1 and View2:
select v1.patientspid, v1.invoiceheader, v2.invoiceline, v2.amount
from view1 v1 inner join view2 v2
on v1.patientspid = v2.patientscid
order by v1.patientspid
If you want to get the results for a patientspid use
where v1.patientspid = 1
and no order by
In this case both PatientsPID and PatientsCID act as your Key. The column names don't have to be the same as long as the data contained in them are linked (Same Data).
Select View1.PatientsPID, View1.AmountPaid, View2.[SomeColumnName]
From View1 inner join View2 on View1.PatientsPID = View2.PatientsCID
Where View1.PatientsPID = 1
Use Join in the From line and you have to set which columns are equal between the two tables. These columns have to contain the same data in order to be able to link. Whatever column names you want to select just place the table name in front of it as show above, this prevents errors in the event of an ambiguous column name
I am using Visual Studio 2017 and I installed the latest crystal reportviewer (22)
What I want is to click a button and create a report from the customer that is selected in the datagridview and the addresses that are shown in the second datagridview.
I managed to do all that but the problem is that a few fields contain numbers which need to be converted to text. An SQL query I would use to do this would be like:
SELECT c.customer_nr, c.status, s.rename FROM CUSTOMERS c INNER JOIN SETUP s on s.id = c.status WHERE s.afk = 'STA'
In my SETUP database I have the columns ID,AFK and RENAME so if the status would be 1 it would convert to text: "ACTIVE", if status = 2 it would convert to "INACTIVE" for example.
I could do something with a formula field like this:
IF ({c.status} = 1) THEN "ACTIVE" ELSE
IF ({c.status}) = 2 THEN "INACTIVE"
but that is not good because i could add another status or change the name in the database etc.
So then I tried with an SQL expression field and I put something like this:
(
SELECT "SETUP"."RENAME" FROM SETUP
WHERE "SETUP"."AFK" = 'STA' AND "SETUP"."ID" = "CUSTOMERS"."STATUS"
)
There must be something wrong because I get the correct conversion but there is only one address in the database but I get 7 pages all with the same address. There should only be one address like I get when I remove the SQL expression field. Where does it go wrong?
* EDIT *
I found the problem. When I create a new database that contains only unique id's then it works. In my original database I have multiple times the id's 1,2,3,4,5 but with different abbreviations in column AFK. Somehow the query looks for the id value and every time it finds this id no matter the AFK value it generates an entry for the address value.
Maybe in the future I will find out how this exactly works for now I have a workaround.
Create a new table for example CrRepSta and add the following entries:
ID,AFK,RENAME
1,STA,Active
2,STA,Inactive
etc
The new query:
(
SELECT "CrRepSta"."RENAME" FROM CrRepSta
WHERE "CrRepSta"."AFK" = 'STA' AND "CrRepSta"."ID" = "CUSTOMERS"."STATUS"
)
And by the way the statement "CrRepSta"."AFK" = 'STA' is not really needed.
I pop into a problem recently, and Im sure its because of how I Join them.
this is my code:
select LP_Pending_Info.Service_Order,
LP_Pending_Info.Pending_Days,
LP_Pending_Info.Service_Type,
LP_Pending_Info.ASC_Code,
LP_Pending_Info.Model,
LP_Pending_Info.IN_OUT_WTY,
LP_Part_Codes.PartCode,
LP_PS_Codes.PS,
LP_Confirmation_Codes.SO_NO,
LP_Pending_Info.Engineer_Code
from LP_Pending_Info
join LP_Part_Codes
on LP_Pending_Info.Service_order = LP_Part_Codes.Service_order
join LP_PS_Codes
on LP_Pending_Info.Service_Order = LP_PS_Codes.Service_Order
join LP_Confirmation_Codes
on LP_Pending_Info.Service_Order = LP_Confirmation_Codes.Service_Order
order by LP_Pending_Info.Service_order, LP_Part_Codes.PartCode;
For every service order I have 5 part code maximum.
If the service order have only one value it show the result correctly but when it have more than one Part code the problem begin.
for example: this service order"4182134076" has only 2 part code, first'GH81-13601A' and second 'GH96-09938A' so it should show the data 2 time but it repeat it for 8 time. what seems to be the problem?
If your records were exactly the same the distinct keyword would have solved it.
However in rows 2 and 3 which have the same Service_Order and Part_Code if you check the SO_NO you see it is different - that is why distinct won't work here - the rows are not identical.
I say you have some problem in one of the conditions in your joins. The different data is in the SO_NO column so check the raw data in the LP_Confirmation_Codes table for that Service_Order:
select * from LP_Confirmation_Codes where Service_Order = 4182134076
I assume you are missing an and with the value from the LP_Part_Codes or LP_PS_Codes (but can't be sure without seeing those tables and data myself).
By this sentence If the service order have only one value it show the result correctly but when it have more than one Part code the problem begin. - probably you are missing and and with the LP_Part_Codes table
Based on your output result, here are the following data that caused multiple output.
Service Order: 4182134076 has :
2 PartCode which are GH81-13601A and GH96-09938A
2 PS which are U and P
2 SO_NO which are 1.00024e+09 and 1.00022e+09
Therefore 2^3 returns 8 rows. I believe that you need to check where you should join your tables.
Use DINTINCT
select distinct LP_Pending_Info.Service_Order,LP_Pending_Info.Pending_Days,
LP_Pending_Info.Service_Type,LP_Pending_Info.ASC_Code,LP_Pending_Info.Model,
LP_Pending_Info.IN_OUT_WTY, LP_Part_Codes.PartCode,LP_PS_Codes.PS,
LP_Confirmation_Codes.SO_NO,LP_Pending_Info.Engineer_Code
from LP_Pending_Info
join LP_Part_Codes on LP_Pending_Info.Service_order = LP_Part_Codes.Service_order
join LP_PS_Codes on LP_Part_Codes.Service_Order = LP_PS_Codes.Service_Order
join LP_Confirmation_Codes on LP_PS_Codes.Service_Order = LP_Confirmation_Codes.Service_Order
order by LP_Pending_Info.Service_order, LP_Part_Codes.PartCode;
distinct will not return duplicates based on your select. So if a row is same, it will only return once.
I have a form with 2 different cascading combo boxes set-up. Each has one box that requeries a second combo box after a selection is made. The second combo has criteria to only show values that correspond with the selection chosen in the first box.
The AfterUpdate() event is with a macro:
Requery
Control Name: StageID
Example: ProjectType is box 1, with choices of either Capital or Development. The selection then influences the drop down on the Stage combo box. The table structure that they are generated from is 3 fields: "StageID", "StageName" and "ProjectType", therefore all 3 fields are in the Stage combo box with only the stage name being shown and the "ProjectType" being linked using criteria: [Forms]![Project Update]![ProjectType]
The SQL are as follows
ProjectType - Value List
Stage -
SELECT Stage.StageID, Stage.StageName
FROM Stage
WHERE (((Stage.ProjectType)=[Forms]![Project Update]![ProjectType]));
Business -
SELECT Business.BusinessID, Business.Business
FROM Business;
Problem Statement -
SELECT ProblemStatements.ProblemStatementID, ProblemStatements.ProblemStatement
FROM ProblemStatements
WHERE (((ProblemStatements.BusinessID)=[Forms]![Project Update]![Combo493]));
The control sources for the Stage and ProblemStatemenet fields are from a table named ProjectList which has the fields ProjectID which is filtering the form as well as the fields ProblemStatementID and StageID. The business and ProjectType fields however have a control source from the "ProblemStatement" table and the "Stage" table respectively.
The combo boxes update fine, however after it is requeried/the Project type is changed I am unable to select a new Stage. If I change it back to the original Project Type the original stage is automatically chosen but I'm unable to select a different one. Also, I can change the stage before I select a projecttype (before the first requery).
I'm having the exact same problem with a Business/ProblemStatement combo, the only difference is the table structure.
Table 1: Business, fields: BusinessID and Business
Table 2: ProblemStatements, fields: ProblemStatementID, BusinessID, ProblemStatement
The SQL for the query that is generating the form is as follows:
SELECT ProblemStatements.BusinessID, Business.Business,
ProjectList.StageID, Stage.ProjectType, ProjectList.ProjectID,
ProjectList.ProjectTitle, ProjectList.SiteID, ProjectList.CodeName,
ProjectList.Type, ProjectList.RegionalGlobal, ProjectList.Category,
ProjectList.Status, ProjectList.StartDate, ProjectList.Sensitivity,
ProjectList.ProblemStatementID, ProblemStatements.ProblemStatement,
ProjectList.Attachment, ProjectList.Keywords, ProjectList.Tracking
FROM (Stage RIGHT JOIN (Site RIGHT JOIN (ProblemStatements RIGHT JOIN
ProjectList ON ProblemStatements.ProblemStatementID =
ProjectList.ProblemStatementID) ON Site.SiteID = ProjectList.SiteID) ON
Stage.StageID = ProjectList.StageID) LEFT JOIN Business ON
ProblemStatements.BusinessID = Business.BusinessID;
I am using the same method on a form that is used strictly for new data entry and it works fine. The form its not working on is used for updating existing records.