Parent Child Relationship in Navigation Form (1 Viewer)

moirakalichman

New member
Local time
Today, 04:47
Joined
Aug 9, 2011
Messages
1
I am using Acess 2010 and am stuck. I have am using a Navigation Form with 4 "sub forms". All are connceted with ID. I want to sync the records so when moving from one form to another they always show the same record. I have not been able to set the parent child relationship. I am looking in Properties in Layout View and cannot find anywhere to set the parent child relationship. Any ideas of what I am doing wrong?
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
im having the same problem. i spent so much time for formating to make everything look so slick and boom. i didn't think that i can't link my main form with a navigation form where i put my forms.

i have relationsship between 2 tables (one to many). to be clear - when i set up a subform - it works perfectly fine. 1 main ID and several subs.
but in NAV form my form doesn't seem to want connect with main table. it just shows me all subrecords (from 2nd "many" table)
damn.. :( and there is no options for parent \ chil link
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:47
Joined
Feb 19, 2013
Messages
16,612
@TipsyWolf - you are responding to a 13 year old thread from someone who has only posted once.

Can't help with your navigation form issue, I don't use it due to its limitations. Easy enough to write your own
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
@TipsyWolf - you are responding to a 13 year old thread from someone who has only posted once.

Can't help with your navigation form issue, I don't use it due to its limitations. Easy enough to write your own
could u please advise me how to use some kinda tab (i dont like tab control cause its lilmited and horisontal only) solution ? i tried to make some kinda of subform where i can click on a button and forms changes and they are should be linked to main table. (cause i have one to many) and i couldnt.

i tried to VBA with bringing 1 out of 6 forms to front with ZOrder msoBringToFront i found in google, but it didn't work for me as i couldnt make proper code. (im noob with VBA)


i would like to make a navigation on the left side and 1 working space where i can change linked forms as i click on associated buttons. this is subform\report in a main form

1710949867323.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:47
Joined
Feb 19, 2013
Messages
16,612
1. Create a main form with your buttons to indicate which form to open
2. Add a subform control - leave the controlsource blank, call it sForm

3. in each button click event put the code

Code:
sForm.SourceObject="name of form you want to appear"

4. if your main form contains a control or controls which defines which records you want to appear add additional code to the relevant button clcik event to populate the linkchild/master properties

Code:
sForm.linkChild="name of field(s) in the subform form to link on"
sForm.linkMaster="name of control(s) on your main form you want to link on"

5. or perhaps you need to apply a filter as well or instead

Code:
With sForm.Form
    .Filter="Somefield=" & me.NameOfControlOnMainform
    .Filteron=true
end with
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
1. Create a main form with your buttons to indicate which form to open
2. Add a subform control - leave the controlsource blank, call it sForm

3. in each button click event put the code

Code:
sForm.SourceObject="name of form you want to appear"

4. if your main form contains a control or controls which defines which records you want to appear add additional code to the relevant button clcik event to populate the linkchild/master properties

Code:
sForm.linkChild="name of field(s) in the subform form to link on"
sForm.linkMaster="name of control(s) on your main form you want to link on"

5. or perhaps you need to apply a filter as well or instead

Code:
With sForm.Form
    .Filter="Somefield=" & me.NameOfControlOnMainform
    .Filteron=true
end with
I tried to make as u advised me, but VBA said "object was not found" or something.
i made a simple template db. could u please explain it to me using this basic template

the problem with Navigation Form is as i change records on main form , navigation form follows only records which TableSub has
the problem with subform\report is i can't change forms. its only one for current record on mainform.
 

Attachments

  • template.accdb
    512 KB · Views: 23

Edgar_

Active member
Local time
Today, 03:47
Joined
Jul 8, 2023
Messages
430
If you wanted to keep the navigation form, an alternative is to set the default value of your foreign key field control to the primary key of the parent form, like parent.parentId
Where parentId is the primary key field name of the main form. Then, in the on current event of the parent form, requery the subform control.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:47
Joined
Feb 19, 2013
Messages
16,612
You are still using a navigation form. You need to start again with an ordinary form.

Navigation forms are intended for simple situations, your description of what you actually require is not clear to me - for example why do you not include the subform in the form it relates to - i.e. make it simpler
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
why do you not include the subform in the form it relates to - i.e. make it simpler
because when i put subform\subreport to my main menu directly - it has spreadsheet style and all data of 1 records = 1 row. its not userfriendly and i simple can't see even 20% of all information i need.

so i have to create a form. put there a subform\subreport. and then i put subform\subreport using not table, but a form i already have with subform\subreport

yeah, i dont know the whole power of access, so i might be doing some real dumb shit :) sorry.
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
If you wanted to keep the navigation form, an alternative is to set the default value of your foreign key field control to the primary key of the parent form, like parent.parentId
Where parentId is the primary key field name of the main form. Then, in the on current event of the parent form, requery the subform control.
hm... i'll try it as well. i never used requery yet, but i have a long night ahead of me.. will be trying to make it work somehow :)
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
If you wanted to keep the navigation form, an alternative is to set the default value of your foreign key field control to the primary key of the parent form, like parent.parentId
Where parentId is the primary key field name of the main form. Then, in the on current event of the parent form, requery the subform control.
In a main form i inserted a form with extra information (from related one to many table) and it doesn't follow parent ID as i click next record.
where exactly i should type parent.parentID. on load event on main form or subform ? or in this ID_TableSub. or just open VBA? is it just parent.parentID or i should add something more ?

in this screenshot i now have parent form with ID 2, but "subform" (its simply another form with extra info) and ID_tablesub should follow the same mainform's ID.
please explain me like u would explain it to 2grader :)

1710965024608.png
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
You are still using a navigation form. You need to start again with an ordinary form.

Navigation forms are intended for simple situations, your description of what you actually require is not clear to me - for example why do you not include the subform in the form it relates to - i.e. make it simpler
i make as u recomended, but this form follows its own records. main form and sub form isn't linked evne though i have a realationship set
1710965314472.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:47
Joined
Sep 21, 2011
Messages
14,301
You need to look at the master/child properties of the subform control.
They would not be linked like that anyway. :(
You would link by employeeid
 

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
You need to look at the master/child properties of the subform control.

navigation form:
-cons. it stays unlinked so when main form changes records - the attached form stays the same. like there is not parent \ child connection.
-pros. it has button so i can switch between 6-7 forms

subform\subreport:
-cons. it has spreadsheet style and all data of 1 records = 1 row. its not userfriendly and i simple can't see even 20% of all information i need. so much space are wasted.
1710967413344.png

-pros. it has parent\chiled connections. when mainform's records changing, this subform shows me every recorded which is linked as in relationship

just adding subform (i mean i created a form and put there all data from non-main form)
-cons. it stays unlinked so when main form changes records - the attached form stays the same. like there is not parent \ child connection.
and i dont know how to switch between 6-7 forms using some buttoms.
pros. no pros for me.

so im having hard time to make some kinda form so it switches between eachothers by clicking some buttons.

the good advice for me was to link forms in the navigation form to main form records, but i simple dont know how to do it exactly.
as i get it , i need to make linked ID in subform follows the main form record (parent record) how to do it ? where ? on lick event? on load ? selecting whole subform or just that ID linked to parent form ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:47
Joined
Sep 21, 2011
Messages
14,301
Pay attention to post #8.
I have never used navigation form. They do not exist in 2007.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:47
Joined
Feb 19, 2002
Messages
43,275
@TipsyWolf Welcome to AWF.
The Navigation form is intended to be used as a menu system. It is not intended to be a mainform/subform link and that is why you can't set the master/child links.

The others have told you that to do what you want - without a lot of code - you need to ditch the navigation form and use a standard form with a tab control.

I've attached a sample application which I built to track medical readings. It started simply about 10 years ago to track my husband's diabetes readings and grew from there. It can be used for multiple people (one is loaded for testing. His name is Elvis) Each tab has a separate subform loaded on it and if relevant, they all sync to the person selected by the combo on the main form. Some of the forms are not linked to a specific person since the household probably uses the same hospital and pharmacy and there may be overlap in other medical practitioners.

As you review this application, pay special attention to the relationship diagram so you can understand how tables are properly linked to implement 1-m relationships. Your diagram shows an incorrect relationship so your data will never sync correctly. Naming all autonumbers "ID" is seriously poor practice and only leads to confusion. Assign an actual name that reflects what table the field is the PK for.

Here's a picture with focus on the Drugs tab for Elvis. Add a new person using the Add person button and add some drugs. Add some visits, etc and you will see that they all stay sync'd. The Doctors/Practices tab isn't tied to an individual. It is shared.
1710984795426.png
 

Attachments

  • MedicalReadingsTracker_20240119.zip
    408.3 KB · Views: 23

TipsyWolf

Member
Local time
Today, 11:47
Joined
Mar 20, 2024
Messages
112
with your help i found best solution for me.
1. in a mainform i put another form (subform) where it has records i need to see as additional info.
1. i set up a master \ child between 2 forms.
1711017442089.png

2. i set up
Code:
ApplyFilter
where condition
Code:
[Category]=1
using MacroBuilder on every button.
so now, everytime i click on 1-2-3 button it changes "category" within the same mainform ID.

1711017239148.png


thank you guys,
thank u very much everyone how posted suggestions for me. love the AWF!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:47
Joined
Feb 19, 2002
Messages
43,275
Not sure why you need macros for anything the controls which are showing numbers should be combo boxes so they show the text value. So you see Jon Jones instead of 4 and Teacher instead of 1, etc
 

Users who are viewing this thread

Top Bottom