12. marts 2003 - 08:36Der 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 )
Efter ti år i London, Madrid, Paris og Utrecht kommer Sabios AI-fokuserede program af arrangementer om kundeoplevelser, ‘Disrupt’, for første gang til Danmark.
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
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.
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
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.
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
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
OK. I think you should also concider buying a book on Access, this will save you much frustration.
thanks for the points.
Synes godt om
Ny brugerNybegynder
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.