Hi All
I have three scripts. Summarise_Bookings, Update_Resbal, and one that opens a Wndow displaying the resulting table details. These scripts run with all windows closed from a buttonbar.
Summarise_Bookings - Summarises Tours per date and sums various numerical qty's.
Update_Resbal - Looks for existing records and updates where neccessary and appends new ones.
A third script that opens the form with :form.view("Resource_Balancing")
Runing these scripts from another script called from the buttonbar gives the "Cannot use funtion in this context" message: see atached image. Running the one script that calls the other two and completes everything as required.
This is the code to update the resbal table from the summary booking table:
Any assistance with this would be appreciated
Thanks
Peter G
I have three scripts. Summarise_Bookings, Update_Resbal, and one that opens a Wndow displaying the resulting table details. These scripts run with all windows closed from a buttonbar.
Summarise_Bookings - Summarises Tours per date and sums various numerical qty's.
Update_Resbal - Looks for existing records and updates where neccessary and appends new ones.
A third script that opens the form with :form.view("Resource_Balancing")
Runing these scripts from another script called from the buttonbar gives the "Cannot use funtion in this context" message: see atached image. Running the one script that calls the other two and completes everything as required.
This is the code to update the resbal table from the summary booking table:
Code:
dim tbl as P dim vTour as c dim vDate as d dim vCount as n vCount = 0 tbl = table.open("summary_tour_day") 'debug(1) tbl.fetch_first() while .not. tbl.fetch_eof() vTour = tbl.tour vDate = tbl.tour_date 'Pause the script for a instant until the user interface has finished repainting. xbasic_wait_for_idle() '-------------------------------------------------- dim tblResbal as P dim qry as P dim nrecs as N nrecs = 0 ' CHECK THIS OUT tblResbal = table.open("resbal") tblResbal.index_primary_put("TDate") query.description = "TourAndDate" query.order = "Tour" query.filter = "tour = VAR->vTour .and. tour_date = {" + VAR-> vDAte + "}" query.options = "U" qry = tblResbal.query_create() nrecs = qry.records_get() IF (nrecs = 0) then qry.drop() 'ui_msg_box("Null Query","There are no records in the Query" ,UI_INFORMATION_SYMBOL) query.order = "" query.filter = "" END 'DO INSERT HERE tblResbal.enter_begin(.T.) tblResbal.tour = tbl.tour tblResbal.tour_date = tbl.tour_date tblResbal.action_day = CDOW(DATE()) tblResbal.action_date = Date() tblResbal.action_time = Time() tblResbal.total_balance_outstanding = tbl.total_balance_outstanding tblResbal.total_total_amount = tbl.total_total_amount tblResbal.total_tot_pax = tbl.total_tot_pax tblResbal.count_tour = tbl.count_tour tblResbal.enter_end(.T.) tblResbal.close() end if if (nrecs > 0) then ' script_play("Test_Message") 'DO RECORD UPDATE HERE tblResbal.change_begin(.T.) tblResbal.action_date = Date() tblResbal.action_time = Time() tblResbal.action_day = CDOW(DATE()) tblResbal.total_balance_outstanding = tbl.total_balance_outstanding tblResbal.total_total_amount = tbl.total_total_amount tblResbal.total_tot_pax = tbl.total_tot_pax tblResbal.count_tour = tbl.count_tour tblResbal.change_end(.T.) tblResbal.close() '-------------------------------------------------- query.order = "" query.filter = "" '-------------------------------------------------- end if '-------------------------------------------------- vCount = vCount +1 tbl.fetch_next() end while tbl.close()
Thanks
Peter G
Comment