Parent Child link - doesn't pass value

miltiadis21

Junior Programmer
Local time
Today, 06:29
Joined
Jul 11, 2007
Messages
44
Hi i am facing a weird problem i have two tables "tblParent" having [ParentId(Autonumber),Parent(text)] and a table "tblChild" having [ChildID(autonumber),Child(text)ChildParentid(Foreign key)] i have link them using the wizard but in the tblChild form the ChildParentid(Foreign key) isn't updated and it is left Null.SO as a result i don't see any related data in the child form because the ChildParentid isn't automatically inserted from the previous form!
I have tried to pass arguments from one form to another and i succeed it but i didn't succeed it to have it working with a filter on a docmd.openform cmd
Anyway i am posting a simple database to demonstrate my problem
I am trying at least 8 hours to fix it from yesterday with no success...
Thanks..
 

Attachments

Last edited:
the wizard doesn't cover all possibilities, it's just a starting point. try adding this to the child form:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    If IsNull(Forms!tblParent!ParentID) Then
        MsgBox "you have to add a parent first.  "
        Me.Undo
        Cancel = True
        Exit Sub
    ElseIf IsNull(Me.ChildParentID) Then
        Me.ChildParentID = Forms!tblParent!ParentID
    End If
    
End Sub
p.s. also add this to the child form load event: DoCmd.RunCommand acCmdSizeToFitForm
let us know how it goes.
 
Yes that Seems to works it automatically enters the data!
I will use this sample in the database i am building with the childid not visible
Thank you! :)

P.S i have include the database fixed for anyone who is going to face the same issue in future
 

Attachments

Users who are viewing this thread

Back
Top Bottom