Send Text box value from one sub form to another sub form (1 Viewer)

bconner

Registered User.
Local time
Yesterday, 23:37
Joined
Dec 22, 2008
Messages
182
Hi All,
I have a form that contains two subforms.
I want the user to be able to double click a field in subform 1 and have it send textbox values to fields in subform 2.
I wrote the code below but it's not working correctly. It captures the global variables and sets the focus to subform2 but doesn't transfer the variable values to the TaskId and YEAR fields in subform2.

Code:
Private Sub ID_DblClick(Cancel As Integer)
'Capture ID and Year in global variables
pv_Task_Id = Me.ID
pv_Task_Year = Me.YEAR

'When the user double clicks the ID field in subform1 move the focus to subform2 and enter a new record
Parent![Frm_Exceptions_subform].SetFocus
DoCmd.GoToRecord , , acNewRec

'Send values captured from subform1 (ID, YEAR) and enter those in subform2 as a new record
Me![Frm_Exceptions_subform].Form!Task_id.SetFocus
Task_id = pv_Task_Id

Me![Frm_Exceptions_subform].Form!Task_Year.SetFocus
Task_Year = pv_Task_Year


End Sub
 

bob fitz

AWF VIP
Local time
Today, 05:37
Joined
May 23, 2011
Messages
4,125
Try this:
Code:
Private Sub ID_DblClick(Cancel As Integer)
'Capture ID and Year in global variables
pv_Task_Id = Me.ID
pv_Task_Year = Me.YEAR

'When the user double clicks the ID field in subform1 move the focus to subform2 and enter a new record
Parent![Frm_Exceptions_subform].SetFocus
DoCmd.GoToRecord , , acNewRec

'Send values captured from subform1 (ID, YEAR) and enter those in subform2 as a new record

Parent.Form.[Frm_Exceptions_subform].Task_id.SetFocus
Parent![Frm_Exceptions_subform].Form.Task_id = pv_Task_Id


Parent![Frm_Exceptions_subform].Form.Task_Year = pv_Task_Year


End Sub
 

bconner

Registered User.
Local time
Yesterday, 23:37
Joined
Dec 22, 2008
Messages
182
screenshot1.jpg
screenshot2.jpg
 

bob fitz

AWF VIP
Local time
Today, 05:37
Joined
May 23, 2011
Messages
4,125
Sorry. Remove "Task_id." from the highlighted line and try again please
 

Users who are viewing this thread

Top Bottom