I have totally lost myself in a loop. Here is what I am trying to do:
Open table
set filter/order
fetch first matching record
open second table
set filter/order
fetch first matching record
edit record in second table
edit record in first table
If I need to enter a new record in the second table, I have no problems. But since I need to find a matching record in the second table so that I can edit it, I am totally brain dead. The filter for the second table should be the matching inv_id fields.
Here is my code when I want to enter a new record in the second table. Can somebody tell me where I need to make my modifications so that I can change the matching record in the second table?
The above code works great. Here is the garbage I have come up with to update a record in the second table, which is not even close to working. The filter is working on the first table, but the code never gets past that. I am not properly filtering/fetching the matching record in the second table, nor do I seem to be updating either record in the first or second table :(
Open table
set filter/order
fetch first matching record
open second table
set filter/order
fetch first matching record
edit record in second table
edit record in first table
If I need to enter a new record in the second table, I have no problems. But since I need to find a matching record in the second table so that I can edit it, I am totally brain dead. The filter for the second table should be the matching inv_id fields.
Here is my code when I want to enter a new record in the second table. Can somebody tell me where I need to make my modifications so that I can change the matching record in the second table?
Code:
dim t_source as P dim t_dest as P dim global vcgInv_ID as c t_source = table.open("nceinvn") 'get here if valid serial number, so now we mark the records query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num= \"\")" query.options = "" qry = t_source.query_create() count = qry.records_get() t_source.fetch_first() 'fetch first in filtered list while .NOT. t_source.fetch_eof() t_dest = table.open("atvendor") t_dest.enter_begin(.t.) t_dest.inv_id = t_source.Inv_id t_dest.atv_id = REMSPECIAL(API_UUIDCREATE()) t_dest.vendor = vcgVendor t_dest.atv_shipno = vcgAtvShipNum t_dest.Rma = vcgRMA '20060705 CKL added t_dest.Ven_out = date() t_dest.enter_end(.t.) xbasic_wait_for_idle() 'Assign value to vcgInv_ID for use in filter when loading form vcgInv_ID = t_source.Inv_id xbasic_wait_for_idle() '20060702 CKL mark atven field to true t_source.change_begin(.t.) t_source.Atven = .t. t_source.change_end(.t.) xbasic_wait_for_idle() t_source.fetch_next() 'fetch the next record, should be none end while t_source.query_detach_all() t_source.close() t_dest.close() xbasic_wait_for_idle() '=======================================================================
Code:
dim t_source as P dim t_dest as P dim global vcgInv_ID as c t_source = table.open("nceinvn") 'get here if valid serial number, so now we mark the records query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num = \"\") .AND. (atven = .t.)" query.options = "" qry = t_source.query_create() count = qry.records_get() t_source.fetch_first() 'fetch first in filtered list 'Assign value to vcgInv_ID for use in filter when loading form vcgInv_ID = t_source.Inv_id while .NOT. t_source.fetch_eof() t_dest = table.open("atvendor") query.filter = "(inv_id = var->vcgInv_ID)" query.options = "" qry2 = t_dest.query_create() count2 = qry2.records_get() t_dest.fetch_first() while .NOT. t_dest.fetch_eof() t_dest.change_begin(.t.) t_dest.Ven_in = vdgDateIn t_dest.change_end(.t.) t_dest.fetch_next() end while xbasic_wait_for_idle() 'Assign value to vcgInv_ID for use in filter when loading form 'vcgInv_ID = t_source.Inv_id 'xbasic_wait_for_idle() '20060702 CKL mark atven field to false t_source.change_begin(.t.) t_source.Atven = .f. t_source.change_end(.t.) xbasic_wait_for_idle() t_source.fetch_next() 'fetch the next record, should be none end while t_source.query_detach_all() t_source.close() t_dest.query_detach_all() t_dest.close()
Comment