In my script I have added in a code that should evaluate whether the status is true or false.... and then adds a record to the transaction record if the status is true.
I did a test and changed all records to status f to see if the script would work as expected.
It skips the first record but it adds records while it continues the while function.
Does anyone see where I am going wrong? I have attached the database training database.zip
many thanks,
[code]
'Date Created: 06-Aug-2011 11:04:27 PM
'Last Updated: 09-Aug-2011 12:27:57 AM
'Created By : weiyentan
'Updated By : weiyentan
'This script goes thru all the contacts and enters the contact id to the transaction table.
dim contacttbl as p
dim transtbl as p
contacttbl = table.open("contact")
transtbl = table.open("transactions")
if exist(year(now()),"transactions","Transyd")
ui_msg_box("Rollover","The subscription , Please add transactions manually. ", UI_STOP_SYMBOL)
end if
contacttbl.fetch_first()
WHILE .not. contacttbl.fetch_eof()
if contacttbl.status = .f. then
contacttbl.fetch_next()
end if
SELECT
CASE contacttbl.type = "Client"
transtbl.enter_begin()
transtbl.date =date()
transtbl.contactid = contacttbl.contactid
transtbl.description = "Subscription Fee"
transtbl.flddebit = 50
transtbl.enter_end(.T.)
CASE contacttbl.type = "Supplier"
transtbl.enter_begin()
transtbl.date =date()
transtbl.contactid = contacttbl.contactid
transtbl.fldcredit = 100
transtbl.description = "Invoice"
transtbl.enter_end(.T.)
END SELECT
contacttbl.fetch_next()
END WHILE
transtbl.batch_end()
transtbl.close()
contacttbl.close()
I did a test and changed all records to status f to see if the script would work as expected.
It skips the first record but it adds records while it continues the while function.
Does anyone see where I am going wrong? I have attached the database training database.zip
many thanks,
[code]
'Date Created: 06-Aug-2011 11:04:27 PM
'Last Updated: 09-Aug-2011 12:27:57 AM
'Created By : weiyentan
'Updated By : weiyentan
'This script goes thru all the contacts and enters the contact id to the transaction table.
dim contacttbl as p
dim transtbl as p
contacttbl = table.open("contact")
transtbl = table.open("transactions")
if exist(year(now()),"transactions","Transyd")
ui_msg_box("Rollover","The subscription , Please add transactions manually. ", UI_STOP_SYMBOL)
end if
contacttbl.fetch_first()
WHILE .not. contacttbl.fetch_eof()
if contacttbl.status = .f. then
contacttbl.fetch_next()
end if
SELECT
CASE contacttbl.type = "Client"
transtbl.enter_begin()
transtbl.date =date()
transtbl.contactid = contacttbl.contactid
transtbl.description = "Subscription Fee"
transtbl.flddebit = 50
transtbl.enter_end(.T.)
CASE contacttbl.type = "Supplier"
transtbl.enter_begin()
transtbl.date =date()
transtbl.contactid = contacttbl.contactid
transtbl.fldcredit = 100
transtbl.description = "Invoice"
transtbl.enter_end(.T.)
END SELECT
contacttbl.fetch_next()
END WHILE
transtbl.batch_end()
transtbl.close()
contacttbl.close()
Comment