Auto Populate a field from one form to another

blallen58

New member
Local time
Today, 18:14
Joined
Jul 10, 2013
Messages
1
I have created two tables one for long term goals (tableA) and one for short term goals (tableB)

Each table has its own PK but in tableB I store the PK of tableA for linking the two tables. The relationship is for each long term goal you can have many short term goals to achieve the long term. I have created a form that has the long term on a main form and the short term in a subform. and the linking of the ID's works correctly.

My problem is that on the main form I have another ID field (not a PK) that when I click a button to add additional long term goals I want the ID field copied and populated when the new data entry form is opened.

The button is created with the wizard to add a new record.

How can I copy the ID from the open form to the same field on the form when the new record button is clicked?
 
Welcome to the forum

A better design would be to have a single goals table with a Yes/No field called IsLongTerm. The difference between those goals is not structural, they only differ by the value of a single dimension.
 
Hi
If want to parse information form one form to another you could use the openargs property
Code:
'Long Term goal Form
Private Sub  btn_onclick()
 
  Dim iID as Integer
 
  iID = Val(me.ID_TEXTBOX.value)
 
  DoCmd.OpenForm "frmShortTermGoal", OpenArgs:= iID
 
End Sub
 
 
'Short tem goal form
Private Sub frmShortTermGoal_Load()
 
  Dim iIDLongTermGoal as Integer
  iIDLongTermGoal = me.OpenArgs()
 
End Sub
 
End Sub

Cheers James
 

Users who are viewing this thread

Back
Top Bottom