I'm newly introduced in visual foxpro and having some difficulties
I have combobox(combo1),listbox(list1),and tables(table1 and table2)
combo1's rowsource is table1.records
If I select a record in combo1, it will display all data from table2 to list1
Is it possible to do this? Thanks for your help :)
Remember this is just a sample built on a 'guess':
Public oForm
oForm = Createobject('SampleForm')
oForm.Show()
Define Class SampleForm As Form
Height = 800
Width=600
DataSession = 2
Add Object cmbCustomers As ComboBox With Top=10, Left=10, Width=250
Add Object lstOrders As ListBox With Top=10, Left=280, Height=780, Width=310
Procedure Init
With This.cmbCustomers
.RowSourceType = 3 && -SQL
.RowSource = "select CompanyName, CustomerId from ('"+;
_Samples+;
"Northwind\Customers') into cursor crsCustomers nofilter"
.ListIndex=1
Endwith
With This.lstOrders
.RowSourceType = 3 && -SQL
.RowSource = "select OrderId, OrderDate, ShippedDate, CustomerId from ('"+;
_Samples+;
"Northwind\Orders') o"+;
" where o.CustomerId = crsCustomers.CustomerId"+;
" into cursor crsOrders nofilter"
.ColumnCount = 3
.ColumnWidths = '70,120,120'
Endwith
Endproc
Procedure cmbCustomers.InteractiveChange
With Thisform.lstOrders
.ListIndex = 0
.Requery()
Endwith
Endproc
Enddefine
Related
This is the code of the init of the form
if !used if !used ("supplier_temp")
SELECT supplier
afields(structure)
CREATE cursor supplier_temp from array structure
else
SELECT supplier_temp
for re = 1 to reccount()
SELECT supplier_temp
go re
_id = supplier_temp.id
_name = supplier_temp.name
_dir = supplier_temp.dir
_cel = supplier_temp.cellphon
_em = supplier_temp.email
scan
update provider set name=_name, address=_dir, cell=_cel, email = _em where control = 1 and id = _id
end scan
end for
delete all
endif
SELECT supplier_temp
APPEND FROM supplier for dispatched = 1
GO TOP
Thisform.Suppliers.RecordSource = "supplier_temp"
Thisform.Suppliers.column1.ControlSource = "supplier_temp.name"
Thisform.Proveedores.column2.ControlSource = "supplier_temp.direntre"
Thisform.Proveedores.column3.ControlSource = "provider_temp.cellphon"
Thisform.Suppliers.column4.ControlSource = "supplier_temp.email"
This is the code for the process button
If thisform.Proveedores.Column1.Check2.Value = 1
thisform.Preclientes.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 2
locate for supplier_temp.control = 2
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
This is the code for the reject button
If thisform.Suppliers.Column1.Check2.Value = 1
if !empty(suppliers_temp.obs)
thisform.Suppliers.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 3
locate for supplier_temp.control = 3
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
endif
The grid is not refresh despite having in the init and in the buttons the commands Thisform.Suppliers.refresh,thisform.Suppliers.setfocus() and
thisform.refresh. When the form is closed and reopened, the grid is refreshed
&& reset the grid control because init() executed twice
Thisform.Suppliers.RecordSource = ""
CREATE cursor supplier_temp from array structure
Thisform.Suppliers.RecordSource = "supplier_temp"
Why does this code show invalid identifier when sum is used in distance and air_time column?
When sum is not used this statement process successfully but using sum I get error? I need to use sum for this statement.
MERGE INTO FACT_COMPANY_GROWTH F
USING (SELECT DISTINCT TIME_ID, FLIGHT_KEY, AEROPLANE_KEY, SUM(DISTANCE) AS TOTAL_DISTANCE, SUM(AIR_TIME) AS TOTAL_AIRTIME
FROM TRANSFORM_FLIGHT T
INNER JOIN TRANSFORM_AEROPLANE A
ON T.FK_AEROPLANE_KEY = A.AEROPLANE_KEY
INNER JOIN DIM_TIME D
ON D.YEAR = T.YEAR
AND D.MONTH = T.MONTH
GROUP BY TIME_ID, FLIGHT_KEY, AEROPLANE_KEY) S
ON (F.FK1_TIME_ID = S.TIME_ID
AND F.FK2_FLIGHT_KEY = S.FLIGHT_KEY
AND F.FK3_AEROPLANE_KEY = S.AEROPLANE_KEY
)
WHEN MATCHED THEN
UPDATE SET
F.TOTAL_AIRTIME = S.AIR_TIME,
F.TOTAL_DISTANCE = S.DISTANCE,
F.TOTAL_NO_OF_FLIGHTS = S.FLIGHT_KEY,
F.TOTAL_NO_OF_AEROPLANE = S.AEROPLANE_KEY
WHEN NOT MATCHED THEN
INSERT(FACT_ID, FK1_TIME_ID, FK2_FLIGHT_KEY, FK3_AEROPLANE_KEY, TOTAL_DISTANCE, TOTAL_AIRTIME, TOTAL_NO_OF_FLIGHTS, TOTAL_NO_OF_AEROPLANE)
VALUES
(NULL, S.TIME_ID, S.FLIGHT_KEY, S.AEROPLANE_KEY, S.DISTANCE, S.AIR_TIME, S.FLIGHT_KEY, S.AEROPLANE_KEY);
USING(
SELECT DISTINCT
TIME_ID,
FLIGHT_KEY,
AEROPLANE_KEY,
SUM(DISTANCE) AS TOTAL_DISTANCE,
SUM(AIR_TIME) AS TOTAL_AIRTIME
...) S
The problem is at UPDATE SET F.TOTAL_AIRTIME = S.AIR_TIME. There are 5 fields defined in S and none is named AIR_TIME.
UPDATE SET
F.TOTAL_AIRTIME = S.TOTAL_AIRTIME,
F.TOTAL_DISTANCE = S.TOTAL_DISTANCE,
I have written the below piece of code to pick a row from web table to process it. The code picks/opens the first row successfully, however, when it is trying to double click the second row, it errors out with an error "Unspecified error". The web table has 7 rows, nevertheless, it is failing. Can some one point out what could be the reason for the failure please?
Set objDesc = Description.Create
objDesc("micclass").Value = "WebTable"
objDesc("html tag").Value = "Table"
Set objList = Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").ChildObjects(objDesc)
oCount = objList.Count
For k =0 To oCount - 1
colName = objList(k).GetRoproperty("cols")
If Trim(colName) = 21 Then 'This is the right table
objList(k).Highlight
rows= objList(k).GetROProperty("rows")
For i = 1 To rows
x = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_x")
y = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_y")
Wait(2)
Set obj = CreateObject("Mercury.DeviceReplay")
obj.MouseDblClick x,y,LEFT_MOUSE_BUTTON
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebEdit("ben_elig_dte"), "ben_elig_dte", "WebEdit", Parameter("elig_date"))
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebList("emp_state_withd_opt_decode"), "emp_state_withd_opt_decode", "WebList", Parameter("withhold_ind"))
Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebButton("Save").Click
Next
Exit For
End If
Next
I'm using PL/SQL and I get the "Not all variables are bound" when I execute the sql expression. I'm selecting data by passing values into 3 parameters. Therefore "host variables" do not help me in here.
SELECT SomeApi1_Api.Get_Part_No(t.or_no, t.l_no, t.rel_no, t.item_no),
t.description,
c.serial_no,
c.lot_batch_no,
t.order_no,
t.line_no,
t.release_no,
SomeApi1_Api.Get_State(t.or_no, t.l_no, t.rel_no, t.item_no)
FROM TableView1 c,
TableView2 t
WHERE c.or_no = t.or_no
AND c.l_no = t.l_no
AND c.rel_no = t.rel_no
AND c.item_no = t.item_no
AND deliv_no IN (SELECT deliv_no
FROM TableView3 a
WHERE a.del_no IN (SELECT DISTINCT dele_no
FROM TableView3 cod,
TableView4 cdi
WHERE cod.deliv_no = cdi.deliv_no
AND cdi.i_id = t.i_id
AND cdi.item_id = t.item_id
AND cdi.co = t.co
AND a.or_no = t.or_no
AND a.l_no = l_no
AND a.rel_no = rel_no
AND a.item_no = item_no))
AND t.i_id = '&A'
AND t.item_id = '&B'
AND t.co = '&C'
I'm at my wits end attempting to make this happen. Currently I have 3 separate queries. For automation purposes I need to get the results of these three queries in one output, I cannot seem to join them properly to get the expected results.
QUERY 1:
SELECT OH.EXTN_HOST_ORDER_REF,
OL.EXTN_HOST_ORDER_LINE_REF,
OL.ORIGINAL_ORDERED_QTY,
OL.EXTN_TENDER_QUANTITY,
OL.EXTN_CUM_PICK_QTY,
OL.SHIPPED_QUANTITY,
OL.EXTN_REFUND_QTY
FROM YFS_ORDER_HEADER OH,
YFS_ORDER_LINE OL
WHERE OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
AND OH.DOCUMENT_TYPE = '0001'
AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx'
ORDER BY PL.EXTN_HOST_ORDER_LINE_REF ASC;
QUERY 2:
SELECT RS.STATUS_QUANTITY AS RETURNED_QTY
FROM YFS_ORDER_HEADER OH,
YFS_ORDER_LINE OL,
YFS_ORDER_RELEASE_STATUS RS
WHERE OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
AND OL.ORDER_LINE_KEY = RS.ORDER_LINE_KEY
AND RS.STATUS = '3700.02'
AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx';
QUERY 3
SELECT RS.STATUS_QUANTITY AS CANCELLED_QTY
FROM YFS_ORDER_HEADER OH,
YFS_ORDER_LINE OL,
YFS_ORDER_RELEASE_STATUS RS
WHERE OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
AND OL.ORDER_LINE_KEY = RS.ORDER_LINE_KEY
AND RS.STATUS = '9000'
AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx';
The query should show NULL values where no data exists from query 2 & 3.
Thanks in advance for your help and advice!
If you are allowed to show both returned and cancelled quantities, the following simple edit should work. Hope this helps.
SELECT oh.extn_host_order_ref,
ol.extn_host_order_line_ref,
ol.original_ordered_qty,
ol.extn_tender_quantity,
ol.extn_cum_pick_qty,
ol.shipped_quantity,
ol.extn_refund_qty,
DECODE (rs.status, '3700.02', rs.status_quantity) AS returned_qty,
DECODE (rs.status, '9000', rs.status_quantity) AS cancelled_qty
FROM yfs_order_header oh
INNER JOIN yfs_order_line ol
ON oh.order_header_key = ol.order_header_key
LEFT OUTER JOIN yfs_order_release_status rs
ON ol.order_line_key = rs.order_line_key
WHERE oh.document_type = '0001' AND oh.extn_host_order_ref = 'xxxxxxxxxxx'
ORDER BY pl.extn_host_order_line_ref ASC;