Avatar billede bojohansen Nybegynder
12. juli 2005 - 21:46 Der er 4 kommentarer og
1 løsning

Relation oprettelse bliver overstyret av access.

Hej.

Som du kan se på dette link

http://www.bojohansen.dk/eksperten/mine_spoersmael/KZ_D3_Relationer.html

Så prøver jeg at oprette en relation mellem T_PersonInfo.Koen og T_Koen.Id (I Funktioner->Relationer)

T_PersonInfo indeholder :
Id:567 Koen:1 og alle de andre.


T_Koen Indeholder :

Id:1 TxtDk:Mand TxtNo:Mann etc.
Id:2 TxtDk:Dame TxtNo:Dame etc.
Etc. Etc.

Hvorfor i alverden kan jeg ikke få lov til at lave en relation som siger

LeftTable=T_PersonInfo Field=Koen | RightTable=T_Koen Field:Id

og derved få feks.:
SELECT T_PersonInfo.NNavn, T_Koen.TxtDk
FROM T_PersonInfo LEFT JOIN T_Koen ON T_PersonInfo.Koen = T_Koen.Id;

Men det vil den bare ikke være med på


og derved får jeg feks.:
SELECT T_PersonInfo.NNavn, T_Koen.TxtDk
FROM T_Koen RIGHT JOIN T_PersonInfo ON T_Koen.Id = T_PersonInfo.Koen;

hvilket er ret så ulogisk en måde at lave SQL'en på for mig.

Ja jeg kan ændre det i Forespørgelses vinduet, men det er jo ganske så meget letter hvis relationen er oprette som jeg vil ha den fra begyndelsen.
Avatar billede terry Ekspert
13. juli 2005 - 12:43 #1
In table design alter the field type of T_PersonInfo.Koen. If you look in the list you will find a wizard which you can use to  make a reference to another table/field, in this case T_koen.ID. This will automatically make a relationship for you.

Then you should be able to the JOIN type in the relationship window. Right click on the thin line and choose from the three radio buttons the one which returns all records from T_PersonInfo

if you can not do this then I susspect that the data type for the foreign key and primary key field are not the same (autonumber and Number (long int))
Avatar billede bojohansen Nybegynder
13. juli 2005 - 15:36 #2
Hi Terry.
Once again your the mann with the answers :-)

Nope that did the excact same thing, and yes
T_Personinfo.Koen = Lang Heltal
T_Koen.Id = Autonumber

But I was under the impression that those two where suppose to work togheter.
Avatar billede terry Ekspert
13. juli 2005 - 19:17 #3
But it would be nice if the answer helped :o)

can you send me your dB so I can take a look?

eksperten@NOSPAMsanthell.dk
remove NOSPAM
Avatar billede terry Ekspert
14. juli 2005 - 10:55 #4
thanks Bo
have a nice day

mvh
Terry
Avatar billede bojohansen Nybegynder
15. juli 2005 - 13:28 #5
For reference to others and to apply to the Eksperten.dk rules about giving email support and points for this on Eksperten.dk being illigal.

Access wil always by default set up the table with a primary key as the Left Table, if you create a relation, in the relations window (Funktioner->Relationer).
To get the Non primary key field on the Left when your building Querys in the Query builder. Insert your desired tables, delete the auto created Joints (Taken from your previous settings).
Now you can make a new join by pulling your Non primary key field on to the Primary Key field, and you wil get your Table.NonPrimaryKey on the Left, Select your join type.
Avatar billede Ny bruger Nybegynder

Din løsning...

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.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester