13. januar 2013 - 17:48Der er
26 kommentarer og 1 løsning
Hent værdi fra andet sted i tabellen
Jeg har en tabel med følgende felter:
KategoriAutoID (nøgle) OverordnedKategoriAutoID (reference til samme tabel) KategoriID SubkategoriID Kategori
Hvor OverordnedeKategoriAutoID referer til KategoriAutoID i samme tabel.
Jeg vil gerne kunne sætte værdien i [KategoriID] til at være, den overordnede [KategoriID] og [SubkategoriID] i den pågældende tabel. Jeg forestiller mig noget i retningen af:
Men man kan tilsyneladende ikke bruge DLookUp i et beregnet felt. Jeg får fejlmeddelelsen "The expression DLookUp("Kat....cannot be used in a calculated column.?
Mit spørgsmål er så hvordan jeg ellers kan realisere det?
The table contains a hierarchical category structure, that's why I have the self reference.
I would like to use the dLookUp to get a value from the same table (thy higher category) and put it into the current table. It shouldn't be in a query.
In this way I should be able to create a sort of recursive function that creates a hierarchical ID like.
You should add the parent category value when you create the record. Normally you would create the record in a form.
You cantm which I think you are trying to do, use Dlookup as a calcualted field in the table design.
Another alternative is to choose Lookup Wizard as the data type for the field. Once you have followed the wizard you will see that the field is now a drop down (combo box) so you can choose the parent vale from a list.
I know how to create a drop down, but that's not the point. What I need is to somehow get a value from another entry in the same table, which will always be the higher category in the hierarchy.
So the category "Animals" might have the sub category 1, and the category "Mamals" have the sub category 1 and the category "Elephants" have the sub category 2.
What I want is to dynamically create a hierarchical ID like the one below, nothing to be entered exept for the sub category "SubkategoriID":
I have actually done something like that before and would be able to do that. But what I would like to do, not to depend on all forms to have this function, is to have the function in the table.
If the function is in the form, then every form that I make to access that table would need to have the function. Also if I decide to recreate the form, I would need to transport the code.
Exactly and then it should correct itself recursively. It's not something that has to be entered, it's something that should be created out of what was entered.
Well, I need something that updates the table, like a sort of a calculated field. I don't need something that makes me dependent on what happens in different forms.
So if I change the category "Animals" from 1 to 2, in the table or through any form, then what is below should be changed:
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.