Relationship form/subform (1 Viewer)

spa856

New member
Local time
Tomorrow, 00:20
Joined
Apr 21, 2023
Messages
26
Hello All,

I have created a DB with 4 tables related in this way
1682063119738.png


I am trying to create a form for create the t_punto_vendita's information.
My question is: T_PUNTO_VENDITA have two input tables T_ BRAND and T_COMUNE and I would like to create a form where the user via two combobox can select in the first one the Brand and in the second one the Comune and then T_PUNTO_VENDITA reflect the key of the two tables in the proper fields and the user can proceed to create the new record in T_PUNTO_VENDITA.
Is it possibile and how?
thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:20
Joined
May 7, 2009
Messages
19,246
just add two combobox, that will save the ID_BRAND from T_BRAND.

rowsouce:
select ID_BRAND, CLIENTE from T_BRAND;
bound column:
1
column widths:
0;1
list width:
1


the second combo will save the ID_COMUNE fom T_COMUNE

rowsurce:
select ID_COMUNE, PROVINCIA from T_COMUNE;
bound column:
1
column widths:
0;1
list width:
1
 

spa856

New member
Local time
Tomorrow, 00:20
Joined
Apr 21, 2023
Messages
26
Thank you for your prompt reply.
In addition,the recordsource of the form will be T_PUNTO_VENDITA, right?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:20
Joined
May 7, 2009
Messages
19,246
In addition,the recordsource of the form will be T_PUNTO_VENDITA, right?
yes, ofcourse.

the two combobox are Bound to ID_BRAND and ID_COMUNE (of T_PUNTO_VENDITA table) respectively.
 

spa856

New member
Local time
Tomorrow, 00:20
Joined
Apr 21, 2023
Messages
26
ok it works.
thank you
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:20
Joined
May 7, 2009
Messages
19,246
what is the relation you showed, for the form?
if for the form, you only need T_PUNTO_VENTITA, not the 2 other tables.
 

spa856

New member
Local time
Tomorrow, 00:20
Joined
Apr 21, 2023
Messages
26
No it was related to another query.
I solved, i was wrong the join type
 

spa856

New member
Local time
Tomorrow, 00:20
Joined
Apr 21, 2023
Messages
26
Last question, I hope.
I set the Home Page form as modal Yes and Pop Up Yes and set the form as default page on opening the application.
Can I hide the All Access Objects frame and the option access Db above? (File, Home etc)
1682069464140.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:20
Joined
May 7, 2009
Messages
19,246
add this code in a Module:
Code:
Declare PtrSafe Function MoveWindow Lib "user32" _
            (ByVal hwnd As LongPtr, _
            ByVal x As Long, _
            ByVal y As Long, _
            ByVal nWidth As Long, _
            ByVal nHeight As Long, ByVal bRepaint As Long) As Long

add code to your Form's Open event:
Code:
Private Sub Form_Open(Cancel As Integer)
    MoveWindow Application.hWndAccessApp, 1024, 2024, 0, 0, 0
End Sub

all your forms must be Pop-up.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:20
Joined
Feb 19, 2002
Messages
43,385
Here's a sample that shows how a many-many relationship works. It shows forms that display the relationship from the perspective of either side of the relationship. In one direction, it uses a subform but from the other direction, it uses a popup. Both methods are valid but one usually makes more sense for your purpose than the other so use whichever makes sense in context.

 

Users who are viewing this thread

Top Bottom