Help with My Query

safril

New member
Local time
Tomorrow, 05:28
Joined
Aug 7, 2021
Messages
14
Hi, I'm a newbie here and having trouble with a query. So I have some tables and queries. When i want to display data from tbl_Kasasi in query qry_PK, the data is not showing. is the relationship wrong? or I make some mistake?

please help ASAP 🙏

1.jpg
3.jpg
2.jpg
4.jpg
 
do not use "Inner Join". it will not show any record if there is No matching record to the
related table.

use your relationship on your first post, but on the Left table of tbl_Kasasi (that is tbl_Terdakwa),
make the relationship Arrow (edit the relationship) to point to tbl_Terdakwa.

also from tbl_terdakwa (related to those 3 small tables), make the relationship arrow (edit relationship) to point
to those 3 tables.
 
do not use "Inner Join". it will not show any record if there is No matching record to the
related table.

use your relationship on your first post, but on the Left table of tbl_Kasasi (that is tbl_Terdakwa),
make the relationship Arrow (edit the relationship) to point to tbl_Terdakwa.

also from tbl_terdakwa (related to those 3 small tables), make the relationship arrow (edit relationship) to point
to those 3 tables.

I'm so confuse about the relationship. Can you repair my relationship design and with the query, please. I've been tried it but it show empty record when i click a button to open frm_PK in frm_Terdakwa.
 

Attachments

Last edited:
you have Correct query there. Only you do not have id_terdakwa = 2 on tbl_Kasasi that is
the reason it is coming blank in the query.
 
you have Correct query there. Only you do not have id_terdakwa = 2 on tbl_Kasasi that is
the reason it is coming blank in the query.

I've changed the relationship Arrow in both relationship design and qry_PK. But when I run frm_Terdakwa and click PK button to open up frm_PK, the query doesn't show any result.

Untitled.jpg


or like this ?

Untitled.jpg


1.jpg


2.jpg
 
Last edited:
see post #4, you Already has the correct query in post #1.
 
I broke one of my own rules to look at your DB. I noticed that in your qry_PK, a lot of other fields are missing from the query besides the three you called out. The missing fields (in the design grid) are to the right of the fields missing from tbl_Kasasi. A lot of them are based on converting information about one or the other of your stored dates.

I agree with arnelgp regarding the direction of the relationships as a possible contributor, but something else isn't quite right either. For instance, in qry_PK, you have a "serial LEFT JOIN" - i.e. a LEFT JOIN of a LEFT JOIN. This is LEGAL in Access. You are missing fields from tbl_Kasasi in your qry_PK, which is a case that comes through a LEFT JOIN. Normally, you would say the fields are missing because having no matching fields in tbl_Kasasi. However, in the same record of qry_PK, you are NOT missing fields from tbl_PK, which you can only have if there ARE matching records in tbl_Kasasi. At the moment, I don't see what is going on, because that is an apparently self-contradictory situation.
 
Hi

The Relationships should be as shown:-

Which produces the Form View as shown.
 

Attachments

  • RI.JPG
    RI.JPG
    110.3 KB · Views: 265
  • Form View.JPG
    Form View.JPG
    146.5 KB · Views: 263
You should also NOT be using Lookup Fields in your tables.
 
Read @isladogs posts on relationships.
 
You have bad records in the tables because they are missing foreign key values. This looks like a hierarchical relationship. For that type of relationship, the FK needs to be required and RI needs to be enforced. Otherwise, you end up with orphans as you have.

Also, you have duplicated data. For example, the id_Terdakwa in tbl_Kasasi is inferred by its relationship to tbl_Banding. It should NOT be duplicated in a lower level table.
 
Hi

The Relationships should be as shown:-

Which produces the Form View as shown.
Awesome, it works fine on the form 'frm_PK', but what about the relationship settings for 'qry_Banding', 'qry_Kasasi', and 'qry_Terdakwa'? can you show me the correct relationship?
 
The database I want to create is simple because it only has to be connected to Microsoft Word via Mail Merge.

So I want to create a table 'tbl_Terdakwa' where later (in the form) we can choose 'Nama_PP', 'Nama_Oditur', and 'Nama_PH' from the existing table.

Each 'Nama_Terdakwa' can file an appeal (in 'tbl_Banding'), cassation (tbl_Kasasi), and judicial review (tbl_PK).
The order: tbl_Terdakwa -> tbl_Banding -> tbl_Kasasi -> tbl_PK

In short, here's the table design for my database:

tbl_Terdakwa
id_TerdakwaAutoNumber
Nama_TerdakwaShort Text
Pangkat_TerdakwaShort Text
NRP_TerdakwaShort Text
id_PPNumber
id_OditurNumber
id_PHNumber

tbl_PP
id_PPAutoNumber
Nama_PPShort Text
Pangkat_PPShort Text
NRP_PPShort Text

tbl_Oditur
id_OditurAutoNumber
Nama_OditurShort Text
Pangkat_OditurShort Text
NRP_OditurShort Text

tbl_PH
id_PHAutoNumber
Nama_PHShort Text
Pangkat_PHShort Text
NRP_PHShort Text

tbl_Banding
id_BandingAutoNumber (?)
id_TerdakwaNumber (?)
tgl_BandingDate/Time

tbl_Kasasi
id_KasasiAutoNumber (?)
id_TerdakwaNumber (?)
id_BandingNumber (?)
Tgl_KasasiDate/Time

tbl_PK
id_PKAutoNumber (?)
id_TerdakwaNumber (?)
id_BandingNumber (?)
id_KasasiNumber (?)
Tgl_PKDate/Time


For example, in mail merge needs, I need a judicial review (from tbl_PK) query with details :
Nama_Terdakwa
Nama_PP
Nama_Oditur
Nama_PH
tgl_Banding
tgl_Kasasi
tgl_PK

I'm really newbie in Access and no one can teach me from basic. I'm really confuse about the relationship design for those tables.
 
See if this now does what you need.

Thanks for your reply. But when I try to run frm_Terdakwa, I'm still can't select Nama_PP from tbl_PP, Nama_Oditur from tbl_Oditur, and Nama_PH from tbl_PH. What should I do?

And,, in frm_PK, it doesn't work when I try to input judicial review's data for the accused (tbl_Terdakwa)
 
Last edited:
Thanks for your reply. But when I try to run frm_Terdakwa, I'm still can't select Nama_PP from tbl_PP, Nama_Oditur from tbl_Oditur, and Nama_PH from tbl_PH. What should I do?

And,, in frm_PK, it doesn't work when I try to input judicial review's data for the accused (tbl_Terdakwa)
Hi
Your frm_Terdakwa was based on a query that was made up of multiple tables.
It only needed to be based on tbl_Terdakwa.

I have modified the frm_Terdakwa so that you are now able to select the values required.

See the attached.
 

Attachments

Hi
Your frm_Terdakwa was based on a query that was made up of multiple tables.
It only needed to be based on tbl_Terdakwa.

I have modified the frm_Terdakwa so that you are now able to select the values required.

See the attached.

Yes, all of the tables based on tbl_Terdakwa. In frm_Terdakwa it works fine.
But I'm still unable to record any data in frm_PK.
I try to edit the relationship design to this :
1.jpg


and the query design of qry_PK like this :
2.jpg


The frm_PK will display what should appear when I try to input some records from tbl_Terdakwa.
But nothing happened, I'm still unable to fill some records in frm_PK with error notification :
Record(s) cannot be added; no corresponding record on the 'one' side.

In my database, each record in tbl_Terdakwa can submit/propose appeal (in frm_Banding), cassation (in frm_Kasasi), and judicial review (in frm_PK). Each record in tbl_Terdakwa can input an appeal (frm_Banding). But when input a cassation (frm_Kasasi), it will required some record from tbl_Banding. As well as frm_PK, it will require some record from tbl_Banding and tbl_Kasasi.
 
Last edited:
It is always best to tell what you did to fix the problem rather than make the OP guess.
 
Yes, all of the tables based on tbl_Terdakwa. In frm_Terdakwa it works fine.
But I'm still unable to record any data in frm_PK.
I try to edit the relationship design to this :
View attachment 97679

and the query design of qry_PK like this :
View attachment 97680

The frm_PK will display what should appear when I try to input some records from tbl_Terdakwa.
But nothing happened, I'm still unable to fill some records in frm_PK with error notification :
Record(s) cannot be added; no corresponding record on the 'one' side.

In my database, each record in tbl_Terdakwa can submit/propose appeal (in frm_Banding), cassation (in frm_Kasasi), and judicial review (in frm_PK). Each record in tbl_Terdakwa can input an appeal (frm_Banding). But when input a cassation (frm_Kasasi), it will required some record from tbl_Banding. As well as frm_PK, it will require some record from tbl_Banding and tbl_Kasasi.
Hi
My apologies, Pat is correct I should have shown how this was fixed.

I say Fixed but in my opinion the Form is not constructed correctly.

I just modified the relationships in the Forms Record Source - "qry_PK to that shown in the attached.
 

Attachments

Users who are viewing this thread

Back
Top Bottom