Solved Problems creating entries in the "wrong" table (1 Viewer)

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
I will definitly do so.
Looked at it shortly yesterday, but I needed more time to get through it.
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
The article I pointed you to is in 3 parts. You only really need to read the first part for your current purposes. Good luck
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
Hi isladogs
I have now read the first part of your article. It gave me a clue I had ignored before. I have not had "Delete records in related tables" checked. So it's done now on all relationships.
In the picture "Records relations" you see what my database looks like today.
I've done some screenshots that I hope will explain what's going on.
In picture 1 ("f_skiva1") you see what the form looks like with the first record. In picture 2 ("f_skiva2") I have clicked on a new blank post and got a blank form. Here I have now filled in a bit about the album I am going to register. When I move to the subform, the entry in the table "t_skiva" is created. So far so good. In picture 3 ("f_skiva3") you see what happens after I fill in the line and click on enter. Already after I selected the song in the second field, from the combo box there, a new entry appears in the field "t_låtar_musik_ID" and that is the problem. Even though I selected a song that is already in the table, it wants to create a new record.
It is important to know here that the first field in the subform is taken from the middle table which gives many to many relations between t_Låtar and t_skiva, the rest of the fields are taken from the table t_Låtar.
The last field must be filled in to create an entry.
The warning box says something like this: The changes you requested in the table were not made because they would have created duplicate index, primary key or relation. Modify data in the fields that contain identical data, delete the index or redefine the index to allow duplicates. Then try again ".

Hope I gave a little more to the problem now.

Leif
f_skiva1.PNG
f_skiva2.PNG
f_skiva3.PNG
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
Thanks for the mention in the textbox!
If you upload the latest version, I'll try & make sense of it. At least the error messages should be in English for me which will help ;)
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
Coming here!
I've deleted the entry with Stevie in t_låtar.

Thanks for trying to help me, I still think there is a slight misconception when I created the database.
Leif
 

Attachments

  • Skivor.zip
    643.6 KB · Views: 122

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
Just had a quick look and its like going back in time to the 1980s!

First of all, you are using outer joins in your relationships and still imposing referential integrity
1595880834455.png


So you will get unwanted effects. Change the join type to INNER on each table shown above
If you get RI errors, remove RI until you have fixed issues preventing RI being imposed

Secondly, unrelated to your problem, you are using attachment fields in 3 of those tables. These will cause your database to bloat dramatically and performance will suffer. Your db is already 6.6MB (though compacting reduced it to 1.4MB) despite only having a few attachments so far. When you add attachments to most records, file size will balloon out of control.
Instead of using attachment fields, store the files externally & save the file paths in your database instead
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
Thanks!
I'll get on to this tomorrow afternoon.
Now it's time for bed.

We'll talk again soon.

Leif
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
Sorry!
Couldn't sleep whitout trying out your tip.
Changing to Inner Join didn't make the table not trying to create new record.
Just saying!
Good night from Sweden.
Leif
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
OK. Sometime tomorrow when its convenient, upload the latest version again (After compacting).
Please tell me exactly what to do to re-create your problem ...or tell me which post to read that has that information.

I'm busy most of the day but will look at it in the evening UK time
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
New database without attachments.

Try to do this.

1. Open the form "f_skiva1"
2. Click on new entry in the main form
3. Click on the arrow to the right in the field "t_Artist/Grupp_namn"
4. Select an artist and fill in the rest of the fields in the main form as you like
5. You can now click in the subform on the first field in the first entry and there enter what position the song has on the disc, often it is "A1"
6. Click on the arrow to the right in the next field "t_Songs_music_title
7. A list of songs from the artist you selected should now appear
8. Select a song from the list
9. Click in the next field "t_Låtar_Längd" or use tab
10. The field "t_Låtar_musik_ID" now shows a suggestion for an ID for the song, this is the next new ID in the table. It should have been the ID in the "t_Låtar" table for the song you selected.
This is what gets weird when I then want to save the record because then a duplicate is created.

Hope you can find what is wrong.

I would like that it was possible to both select songs from the table "t_Låtar" without creating a new record and then a duplicate and that you could also enter a song that was not in the table "t_Låtar" and that it THEN had been created a new post.
 

Attachments

  • Skivor.accdb
    1.6 MB · Views: 127

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
Thanks Leif.
The instructions seem very clear.
All being well, I'll have a look this evening, UK time, and hopefully will be able to assist.
If anyone else wishes to look at it beforehand, that's absolutely fine by me
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
Hi
Just a quick update. I started to look at the form last night but found difficulty understanding it despite your instructions.
Whilst working on it, my workstation froze & I had to reset to recover it.
On restarting it went into a disk check which was still running several ours later when I went to bed.
This morning the section of my G drive where all my files are stored is corrupt & unreadable! Grrr :eek: (n)

Whilst I doubt very much its anything to do with your app, my priority for the next few days will have to be recovering as many of my files as possible from various backups and hopefully fixing the G drive
I may not be able to look at your app properly for some time. Sorry!
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
I'm so sorry to hear this @isladogs.
Glad though that my app isn't the problem.
It works fine fore me in general.

Hope it will work out allright for you, and that I'll here from you soon again.

Is there anyone else who will look at my problem?

Leif
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,221
I very much doubt it was the problem though my PC is almost unuseable this morning.
Its going to take many hours to put right!
 

bob fitz

AWF VIP
Local time
Today, 05:37
Joined
May 23, 2011
Messages
4,726
If I select "Adele" on a new main form record and then select "Skyfall" in the sub form what number should appear in t_Låtar_musik_ID?
Should it be 561
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
YES! Thats the right ID for Skyfall in the table t_Låtar.
But i don't get that number when I try.
What form are you using? f_Skiva1?
And are you trying to write in a new record from Adele with the song Skyfall on the first side?
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
I've downloaded my own database from this thread and tried to do what you've done Bob.
And this is what I get.
Skärmklipp.PNG
 

bob fitz

AWF VIP
Local time
Today, 05:37
Joined
May 23, 2011
Messages
4,726
Looking a little more closely at your table structure has left me more confused than when I started. You have tables with fields that are named as though they would be a Primary Key but in fact you have no Primary key. You also have quite a few Lookup fields in your tables. Obviously I do not understand the language or your table relationships. I'm sorry but I can not help with this.
 

lodmark

Member
Local time
Today, 06:37
Joined
Jul 24, 2020
Messages
232
Thanks for Trying Bob!
The ID_Key is from the creation of the table, I've later change it after @isladogs suggested it to get a unique primary key combined by two fields.
 

Users who are viewing this thread

Top Bottom