473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Linking Child and Parent Fields

Hello!

I have a form that opens with the click of a toggle button on another form. I would like to link the child and parent fields of the forms for data input but am not experienced enough with codes to write it myself. Can someone help me with this?

Parent fields are
[Forms]![Add New Subfunctions]![CCN]
[Forms]![Add New Subfunctions]![UIC]
[Forms]![Add New Subfunctions]![Sub #]
[Forms]![Add New Subfunctions]![Sub CCN]

Child fields are
[Forms]![Algorithm YES]![CCN]
[Forms]![Algorithm YES]![UIC]
[Forms]![Algorithm YES]![Sub #]
[Forms]![Algorithm YES]![CCN Subfunction_SubCCN]

I already have an OnOpen macro that opens to a new record. Any help would be appreciated. Thanks.
Sep 22 '06 #1
7 6377
PEB
1,418 Expert 1GB
Hey man!

Do you have relationships between your tables?

If Yes... Pls use the Form Wizard! Choose Main Sub Form Wizard and fill in... There is a possibility just like you want...

It will create instaed you!

:)

And then you' ll see the code!

:)
Sep 22 '06 #2
Hey man!

Do you have relationships between your tables?

If Yes... Pls use the Form Wizard! Choose Main Sub Form Wizard and fill in... There is a possibility just like you want...

It will create instaed you!

:)

And then you' ll see the code!

:)
Will I still be able to open the form by selecting one of the toggle buttons? I didn't create a subform becuase it was actually a separate form that opened on a Yes/No toggle. How do I do this....
Sep 22 '06 #3
PEB
1,418 Expert 1GB
In fact this wizard can create 2 or more separate forms linked between them.
When U press the bouton for the form when the respective form is open the bouton stay pressed! When you press it an other time it closes the form!

Is this something convenable for You?
Sep 22 '06 #4
In fact this wizard can create 2 or more separate forms linked between them.
When U press the bouton for the form when the respective form is open the bouton stay pressed! When you press it an other time it closes the form!

Is this something convenable for You?
Well that sounds perfect....!
When using the wizard...how do I make the subform show up as a button? I just need them to be able to choose becuase there are different forms based on each choice.
Sep 22 '06 #5
PEB
1,418 Expert 1GB
In fact it doesn't appears subform, but a linked form to the main one...

In fact you want a check bouton... When it is checked on of the forms is opened when is not checked the other one is opened doesn't it?
Sep 22 '06 #6
In fact it doesn't appears subform, but a linked form to the main one...

In fact you want a check bouton... When it is checked on of the forms is opened when is not checked the other one is opened doesn't it?
Huh? I think I am confused now.

Previously I had three forms....One main form with information and a choice of Yes/No. When Yes was selected a form popped up for data entry. When No was selected a different form popped up for data entry. The problem was there was no link to the parent form so the data entered was not going to the tables.

When I used the subform wizard, it insered the form I chose into the main form. There is no button, it is just in the main form always.

I need to still have only the main form show with the choice of Yes/No to open these subforms.

You mention boxes for this but my subforms are simply always on the main form. I would like the linked subforms but don't know how to do that.
Sep 22 '06 #7
PEB
1,418 Expert 1GB
Ok...

My idea is to get the linking code from the Wizard, but maybe will be more simple to give you it here..

This is the code generated by my wizard for
main Form: Objects
sub Form: Object_info

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Sub Form_Current()
  5. On Error GoTo Form_Current_Err
  6.  
  7.     If ChildFormIsOpen() Then FilterChildForm
  8.  
  9. Form_Current_Exit:
  10.     Exit Sub
  11.  
  12. Form_Current_Err:
  13.     MsgBox Error$
  14.     Resume Form_Current_Exit
  15.  
  16. End Sub
  17. Sub ToggleLink_Click() 'the sub for the bouton
  18. On Error GoTo ToggleLink_Click_Err
  19. default_object_value = Me.[ID_obj]
  20.     If ChildFormIsOpen() Then
  21.         CloseChildForm
  22.     Else
  23.         OpenChildForm
  24.         FilterChildForm
  25.     End If
  26.  
  27. ToggleLink_Click_Exit:
  28.     Exit Sub
  29.  
  30. ToggleLink_Click_Err:
  31.     MsgBox Error$
  32.     Resume ToggleLink_Click_Exit
  33.  
  34. End Sub
  35. Private Sub FilterChildForm() 'Filters the sub form by the specified field
  36.  
  37.     If Me.NewRecord Then
  38.         Forms![Object_info].DataEntry = True
  39.     Else
  40.         Forms![Object_info].Filter = "[ID_obj] = " & Me.[ID_obj]
  41.         Forms![Object_info].FilterOn = True
  42.     End If
  43.  
  44. End Sub
  45. Private Sub OpenChildForm()
  46.  
  47.     DoCmd.OpenForm "Object_info", acFormDS
  48.     If Not Me.[ToggleLink] Then Me![ToggleLink] = True
  49.  
  50. End Sub
  51. Private Sub CloseChildForm()
  52.  
  53.     DoCmd.Close acForm, "Object_info"
  54.     If Me![ToggleLink] Then Me![ToggleLink] = False
  55.  
  56. End Sub
  57. Private Function ChildFormIsOpen()
  58.  
  59.     ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Object_info") And acObjStateOpen) <> False
  60.  
  61. End Function
  62.  
  63.  

So to adapt this code to your Forms can you give me the names of your forms and their respective fields?

And also the name of your toggle bouton?

:)
Sep 23 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
2
by: Mike Boozer | last post by:
I have two subforms on my main form. I want the records on subform B to correspond with the records on subform A which they do. However, I want the records on subform A to let me know if there is a...
4
by: Erik Leunissen | last post by:
Hello all, I want to distribute a shared library (lets call it "parent.so"), which, in turn, is used to create shared libs by invoking the GNU linker (lets call these shared libs "child.so"). ...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
1
by: ppwlee | last post by:
Hi, I have created a main form with 2 subforms, Both subforms are in datasheet view. I want to be able to pick a record from subform1 and the corresponding linked record (created by a...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
6
nev
by: nev | last post by:
I have placed fields on form using datadesigner. I have a parent, child and childchild table. When I navigate the parent, naturally the child and childchild follows. Due to certain requirements, I...
3
by: 6afraidbecause789 | last post by:
Think school - students - discipline interventions - misbehaviors - staff for this one....On a mainform frmStudentInterventions, I have linked a subform (sfrmMisbehaviors) with another subform...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.