TOPIC: Key field is empty in Access control
#871
Key field is empty in Access control 3 Years, 3 Months ago
Sorry for my English.

I've just started to study Suneido and yesterday I 've found a bug (or a feature??)

Using standard example from User's Manual (see Going Further -> Master-Detail Relationship) i've found that key value from the header table is empty (you should slightly modify example to add key field, i.e. 'invoice' in Access control like this):

Code:


My_EnterInvoices
Controller
    {
    Controls:
        (Access
            title: "Enter Invoices"
            invoice
            (Vert
                (Horz invoice_number Skip customer Skip invoice)
                (Skip)
                (Browse
                    "invoicelines",
                    columns: (product, qty, price, total_price)
                    linkField: invoice,
                    name: "invoice"')
            )
        )
    }



Field 'Num' in Access Control is Empty (thow evidently it Has value, you can use Brose control to check invoice table)! How can I fix it?

See attached file
 
 
#872
Re:Key field is empty in Access control 3 Years, 3 Months ago
See attached file
 
 
#873
Re:Key field is empty in Access control 3 Years, 3 Months ago
I think the problem is because you now have two controls with the same "name" (invoice). Currently, Suneido does not support this. You can do it by giving one of them a different field name and using a rule for the other field name so it has the same value.

See: Multiple controls for a single field

If you just put this on the screen for "debugging", you can use Current > Inspect instead.

Hope that helps.
 
 
Last Edit: 2008/02/20 17:44 By sunadmin. Reason: update forum link
 
andrew
 
#874
Re:Key field is empty in Access control 3 Years, 3 Months ago
Thank you for your answer, Andrew. I done this, bit it doesn't work again.

1) deleted field 'invoice' from browse control
2) renamed field 'invoice' in master record to 'invoice_main' (of course, I renamed index and Rule too)

So code now looks like this:

Code:

Controller
{
Controls:
(Access
title: "Enter Invoices"
invoice
(Vert
(Horz invoice_number Skip customer Skip invoice_main)
(Skip)
(Browse
"invoicelines",
columns: (product, qty, price, total_price)
linkField: invoice,
name: "invoice_main"')
)
)
}



But the field in Access contol empty again... (though by using Inspect I see it has data). Then I try to manually change field 'invoice_main', it works OK and cascade updating becomes. But after that Access shows new value in ALL records (though really all records have different values). But if I try to manually change invoice_main in NEW record, warning appears: "Record cannot be updated or deleted because it is used".
 
 
#875
Re:Key field is empty in Access control 3 Years, 3 Months ago
Now you have "invoice_main" twice. Put the top one back to "invoice" (and the Field_ and Rule_). Both tables should still have a field called "invoice". The column on the browse is still called "invoice". The other name (e.g. invoice_main) is only used as the name: of the Browse on the Access. Sorry, it is a little confusing.

And as explained in the other forum post you need:

Rule_invoice_main

function ()
{ return .invoice }


WARNING: I think there are problems if you allow users to change this field manually (type in a new value) on old (existing) records because the browse line items will not automatically get updated. We normally use a hidden timestamp field so we do not have this problem.
 
 
andrew
 
#876
Re:Key field is empty in Access control 3 Years, 3 Months ago
Thank you, Andrew.