One form to update Two tables ID (1 Viewer)

nashfaq

Registered User.
Local time
Today, 20:23
Joined
Oct 17, 2018
Messages
28
Hi Team

i am new, i have Two Table
PersonalDetails (Code, Name, Contact) and
other Table EducationDetaits (Code, Degree)

i want to have a form that will populate "Code" in both tables.

can you please help me how can i do that.

Code is primary Key in Both Tables.

kindly suggest
Regards
Nasir
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:23
Joined
May 7, 2009
Messages
19,242
here is a sample to begin with.
 

Attachments

  • code.zip
    28.9 KB · Views: 52

nashfaq

Registered User.
Local time
Today, 20:23
Joined
Oct 17, 2018
Messages
28
Hi freind

but i dont need any sub form...
Also my relation is ONE to ONE.
Code is Primaty Key in Both Tables.


kindly suggest.

regards
Nasir
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:23
Joined
May 7, 2009
Messages
19,242
I find it hard to create the form you need.
there is subform in the attached.
but now it appears as if it is a textbox.
only one degree can be entered to it (1 on 1).
 

Attachments

  • code.zip
    41.1 KB · Views: 47

Minty

AWF VIP
Local time
Today, 17:23
Joined
Jul 26, 2013
Messages
10,371
That sounds like a poor design. It should be a one to many relationship.
What happens when a person has a second degree ?

Arne's original subform design is perfect for this.
 

nashfaq

Registered User.
Local time
Today, 20:23
Joined
Oct 17, 2018
Messages
28
Hi arnelgp

thanks for help, i will design my form as i required,

the relation is ONE to ONE, degree is just a case i mention for explaining my requirement.

thanks again.

Regards
Nasir
 

nashfaq

Registered User.
Local time
Today, 20:23
Joined
Oct 17, 2018
Messages
28
here is a sample to begin with.

hi Arnelgp

please explain the below code your used.

Private Sub Form_Current()
On Error Resume Next
If Me.NewRecord And Screen.ActiveControl.Name = "Degree" Then
Me.Code.SetFocus
End If
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = Trim(Me.Parent!Code & "") = ""
If Not Cancel Then Cancel = DCount("*", "EducationalDetails", "Code=""" & Nz(Me.Parent!Code, "0") & """") <> 0

End Sub

regards
Nasir
 

Users who are viewing this thread

Top Bottom