antonyx
Arsenal Supporter
- Local time
- Today, 18:09
- Joined
- Jan 7, 2005
- Messages
- 556
hello..
imagine that FormA and FormB both use FormX while they are open to perform a similar task..
at the moment im using something like this..
FormA & FormB
txtControl will be placed on both FormA and FormB
the purpose of FormX is to search records.. and transfer a value back to one of the two forms.. so at the moment.. when FormX is ready to transfer the value.. i am using this..
this is fine and works like a treat..
HOWEVER..
i also require txtControl2 on FormA and FormB to be populated in the same way..
so what i am doing at the moment is this.. i create a duplicate form called FormX2 and use this..
i dont want a duplicate form like this..i want 1 FormX and i want that FormX to know which control was used to open it..
so if you are focused on txtControl1-FormA and the after update of txtControl1 triggers FormX to open.. then the name of that control can be transfered to FormX and placed in an unbound textbox.. lets call it txtFromControl
then i could use something like this..
this way FormX will know which control has opened it.. and will know which control to transfer its value to when closed..
i hope that is clear.. i wait patiently for your wisdom..
imagine that FormA and FormB both use FormX while they are open to perform a similar task..
at the moment im using something like this..
FormA & FormB
Code:
Private Sub txtControl_AfterUpdate()
DoCmd.OpenForm "FormX"
End Sub
txtControl will be placed on both FormA and FormB
the purpose of FormX is to search records.. and transfer a value back to one of the two forms.. so at the moment.. when FormX is ready to transfer the value.. i am using this..
Code:
Private Sub btnTransfer_Click()
If CurrentProject.AllForms("FormA").IsLoaded Then
Forms!FormA.txtControl = newID
Forms!FormA.SetFocus
DoCmd.close acForm, "FormX"
ElseIf CurrentProject.AllForms("FormB").IsLoaded Then
Forms!FormB.txtControl = newID
Forms!FormB.SetFocus
DoCmd.close acForm, "FormX"
End If
End Sub
this is fine and works like a treat..
HOWEVER..
i also require txtControl2 on FormA and FormB to be populated in the same way..
so what i am doing at the moment is this.. i create a duplicate form called FormX2 and use this..
Code:
Private Sub btnTransfer_Click()
If CurrentProject.AllForms("FormA").IsLoaded Then
Forms!FormA.txtControl2 = newID
Forms!FormA.SetFocus
DoCmd.close acForm, "FormX2"
ElseIf CurrentProject.AllForms("FormB").IsLoaded Then
Forms!FormB.txtControl2 = newID
Forms!FormB.SetFocus
DoCmd.close acForm, "FormX2"
End If
End Sub
i dont want a duplicate form like this..i want 1 FormX and i want that FormX to know which control was used to open it..
so if you are focused on txtControl1-FormA and the after update of txtControl1 triggers FormX to open.. then the name of that control can be transfered to FormX and placed in an unbound textbox.. lets call it txtFromControl
then i could use something like this..
Code:
Private Sub btnTransfer_Click()
txtFromControl = ThisControl
If CurrentProject.AllForms("FormA").IsLoaded Then
Forms!FormA.ThisControl = newID
Forms!FormA.SetFocus
DoCmd.close acForm, "FormX"
ElseIf CurrentProject.AllForms("FormB").IsLoaded Then
Forms!FormB.ThisControl = newID
Forms!FormB.SetFocus
DoCmd.close acForm, "FormX"
End If
End Sub
this way FormX will know which control has opened it.. and will know which control to transfer its value to when closed..
i hope that is clear.. i wait patiently for your wisdom..