Combo box selections creating new records v.s. adding to a parent record (1 Viewer)

tmguru

Registered User.
Local time
Yesterday, 19:18
Joined
Apr 8, 2018
Messages
19
Hi all. I created a database from an Excel import and used the Table Analyzer to determine the recommended splits. The Excel spreadsheet was used to keep track of purchases for a budget. I used the recommended table split choices in the Table Analyzer and ended up with these tables:

- Table 1 (the renamed original import) with ID link and lookups to the remaining three tables for the 5 fields I use) :
- tblCategories (used for my budget categories)
- tblItems (used for the item purchased, date and cost)
- tblSuppliers (the seller of the item)

The last three tables were created with parent and child records. I created a form for data entry and dragged the fields to the form that I wanted to use a dropdown choice to reduce user errors. I first selected ComboBox on the design tab which then walked me through the choices and created the sql statement used in the row source for each of the three last tables. The control source for each is the relevant field name in each table. For example the tblSuppliers has Supplier in the control Source, etc. After some tweaking of the bound columns which defaulted to 1, I got the the form to work. Mostly.

Maybe this is an expectation problem and not a real problem but new records (which in my view should be child records if the parent record already exists) are being created as new records duplicating the parent record with the same name and with a new child with the new data. Here is the sql in the Row Source property:

SELECT [tblCategories].[ID], [tblCategories].[Category] FROM tblCategories ORDER BY [Category];

I do want to create new parents as needed in all but one table (tblCategories). I changed the Limit to List property on that table to Yes but set to no on the the other two. I have looked at what I can but can't figure this out. It may need some sql someplace but I don't know what or where.

If it helps I attached a zip file with a combo box property sheet for Categories and a relationship view for all tables.

I'd really appreciate some guidance!

tmguru
 

Attachments

  • Pictures.zip
    23.3 KB · Views: 421

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:18
Joined
May 7, 2009
Messages
19,246
First make your relation an outer join. Yiu will not be able to add new record to the related table with the relation you have.

On your combo add a code to notInList event. Use insert query to your category. The Response parameter should be set to acErrDataAdded.
 

tmguru

Registered User.
Local time
Yesterday, 19:18
Joined
Apr 8, 2018
Messages
19
Arnelgp, everything is working perfectly now! Thanks very much for your suggestions.


-tmguru :)
 

Users who are viewing this thread

Top Bottom