Hi
Can anyone see what I'm missing here.
I'm stock on this one...
If any one could't help it would be much apriciaded..
I Have 2 functions function one calls function 2 in the end, the problem as I see it is on function 2
This is the first function:
This one seams to work as I don't get any errors
Function 2:
On this one I get an error saying "attempt to index local 'tbCPRList' (a nil value)
I've been going over this some times now and I think I've gone blind to the problem... maybe some fresh eyes can see where I'm going wrong.
Cheers,
Jonas
Can anyone see what I'm missing here.
I'm stock on this one...
If any one could't help it would be much apriciaded..
I Have 2 functions function one calls function 2 in the end, the problem as I see it is on function 2
This is the first function:
Code:
function BetalEnhed(strEnhed, strDato) strListPay = "Nej"; local tbCPR ={}; local tbMedlem = SQLite.QueryToTable(db, "SELECT * FROM tMedlem where Enhed = "..Enclose(Encrypt(strEnhed))); if tbMedlem and tbMedlem.Rows > 0 then for i,v in tbMedlem.Data do --Add each item returned from the above query to the table Table.Insert(tbCPR, i, Decrypt(tbMedlem.Data[i]["CPR"])); end else Dialog.Message("ERROR", "Der opstod en fejl i betaling", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end if tbCPR and Table.Count(tbCPR) > 0 then v = Table.Count(tbCPR); for i,v in tbCPR do SQLite.Query(db, "Insert into tBetaling(CPR, Betaling, Paied) values(".. Enclose(Encrypt(tbCPR[i]))..", "..Enclose(Encrypt(strDato))..", "..Enclose(Encrypt(strListPay)).." )", nil); --ListBox.AddItem("ListBox1", MyDecrypt(tbMedlem.Data[i]["Fornavn"]).." "..MyDecrypt(tbMedlem.Data[i]["Efternavn"]), MyDecrypt(tbMedlem.Data[i]["CPR"])); end else Dialog.Message("ERROR", "Der opstod en fejl i betaling", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end MissingPaymentToLB(strListPay); end
Function 2:
Code:
function MissingPaymentToLB(strListPay) local tbPayment = SQLite.QueryToTable(db, "SELECT * FROM tBetaling WHERE Paied = "..Enclose(Encrypt(strListPay))); ListBox.DeleteItem("ListBox1", -1); ListBox.SetUpdate("ListBox1", false); if tbPayment and tbPayment.Rows > 0 then local tbCPR ={}; for i,v in tbPayment.Data do Table.Insert(tbCPR, i, Decrypt(tbPayment.Data[i]["CPR"])); end if Table.Count(tbCPR) > 0 then for i,v in tbCPR do local tbCPRList SQLite.QueryToTable(db, "SELECT * FROM tMedlem Where CPR = "..Enclose(Encrypt(tbCPR[i]))); ListBox.AddItem("ListBox1", Decrypt(tbCPRList.Data[i]["Fornavn"]).." "..Decrypt(tbCPRList.Data[i]["Efternavn"]), Decrypt(tbCPRList.Data[i]["CPR"])) end end end ListBox.SetUpdate("ListBox1", true); end
I've been going over this some times now and I think I've gone blind to the problem... maybe some fresh eyes can see where I'm going wrong.
Cheers,
Jonas
Comment