Avatar billede oyejo Nybegynder
12. marts 2003 - 08:36 Der er 9 kommentarer og
1 løsning

Check and create new records in to joined tables from a form with

I’ve got 2 tables, the HeadTab and the DetailTab  that are joined together.

They are joined by the HeadTabs primarykey, HeadTabID and a field with the same name in the DetailTab.

I want to make a form where I can make new records in both tables. If the data to the HeadTab are exact like a record that already exist  in the table, the DatailTab shall be linked to this table. Then it will not be made a new record in the HeadTab.

I don’t want the popup for the parameterqueries, because I want to make the selection from comboboxes or something like that.

Do I have to use Visual Basic? 

Du kan svare både på engelsk og dansk ( er norsk J )
Avatar billede terry Ekspert
12. marts 2003 - 09:19 #1
Hope I understand your question.
Yop make  two tables one with the HeadTab and one with the DetailTab. Then you should be bale to use the form wizard to create a form containing a sub form. The main form should display information on HeadTab and the subform information on DetailTab.
No you shoulkd NOT need to use VB
Avatar billede terry Ekspert
12. marts 2003 - 09:19 #2
Yop  = You
Avatar billede terry Ekspert
12. marts 2003 - 09:21 #3
In the form wizard you choose which tables you want to use in the form and Access will see that there are two related tables. Follow the instructions and see how it goes. It should be quite easy if they are related.
Avatar billede oyejo Nybegynder
12. marts 2003 - 10:01 #4
I used the wizard and made the form with the subform.
Do I have to make a query based on the form? Because first I have to check the HeadTab for records with the same data. If I find a record in the HeadTab, I use this record. Then I only make a new record in the DetailTab and link this to the already existing record in the HeadTable
Øyvind
Avatar billede terry Ekspert
12. marts 2003 - 10:16 #5
Not quite sure what you are trying to do?
Records in the HeadTab table should be unique so there should only be one!

If the wizard has made your form with a subform then you can enter a new record in the main form and then add related records in the sub form.
Avatar billede terry Ekspert
12. marts 2003 - 10:35 #6
An example: In an Order you will have an order header (unique) which contains information about the customer, infromation wich exists only once. Then normally at least one detail record containing information on each item purchased.

So when you create the order you enter the main order infromation in the header and then each item purchased in the sub form. If at a later date you look at this order again then you will see the related (detail) records.
Avatar billede oyejo Nybegynder
12. marts 2003 - 10:46 #7
The value of the HeadTabID is unique for every record.
But I also want that the combination of the other fields should be unique. For instance: there are 2 other field in the table.
In one record field 1 have value "a" and field 2 have value "b"
If I type "a" in field 1 and "b" in field 2 in the form, "The form should make a new record in the DetailTab" and link this record to the already existing record in the HeadTab.
Sorry I'm so bad to explain
Avatar billede terry Ekspert
12. marts 2003 - 12:41 #8
are you saying that more than one field is used in your primary key for HeadTabID? If this is correct then You also need all three fields as the foreign key in your DetailTab.

To make a primary key from thre fields you open the table in design view. Then holding the Ctrl down select the three field and then press on the key icon on the menu. Then you need to alter the design of DetailTab so that the foreign key contains all three fields. NOW I suggest you delete the forms and use the wizard again to create them. Access should see that there are three fields in the primary and now when you create records in HeadTabID and DetailTab they will be releated on ALL THREE fields
Avatar billede oyejo Nybegynder
12. marts 2003 - 14:57 #9
Thanks Terry,  I'll try. If I can't make it. I have to ask again later. Øyvind
Avatar billede terry Ekspert
12. marts 2003 - 18:17 #10
OK. I think you should also concider buying a book on Access, this will save you much frustration.

thanks for the points.
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