[RESOLVED]Referring to a subform from another window
Hi, I am trying to write a procedure that will allow the user to click a button on a subform, which opens another window, the user then selects the record they want and then clicks a button on this window to insert the contents of the second windows text box into the previous subforms textbox.
The following is the code I tried, where tbl_script_details Subform is the name of the subform
Code:
Private Sub Command5_Click()
Dim importString As String
test_script.SetFocus
importString = test_script.Text
tbl_script_details.script_test_details.Text = importString
End Sub
When I try to run this I get a object not found error. Thanks
Re: Referring to a subform from another window
Quote:
Hi, I am trying to write a procedure that will allow the user to click a button on a subform, which opens another window, the user then selects the record they want and then clicks a button on this window to insert the contents of the second windows text box into the previous subforms textbox.
Hi I suppose your using MS Access forms and not vb6.0 forms.Am I right?You mean to say that the data selected in the current window will be transferred to a textbox in another window(previous form)?
:) :) :)
Re: Referring to a subform from another window
Quote:
Originally Posted by KGComputers
Hi I suppose your using MS Access forms and not vb6.0 forms.Am I right?You mean to say that the data selected in the current window will be transferred to a textbox in another window(previous form)?
:) :) :)
Thats correct, yes.
Re: Referring to a subform from another window
Try this one and let me know...
VB Code:
Private Sub Command2_Click()
Dim importString As String
test_script.SetFocus
importString = test_script.Value
Form_tbl_script_details.script_test_details.Value = importString
End Sub
:) :) :)
Re: Referring to a subform from another window
Well, I have made no headway with this problem, after scouring the net for help on this, including msdn i seem to be still no closer to figuring this out.
The following code snippet shows some of the various permutations I have been trying without any luck. Hope somebody can help me with this because I am fresh out of ideas. Man, I thought this would be easy to do!
VB Code:
Dim importString As String
test_script.SetFocus
importString = test_script.Text
'[forms]![MainFormName]![SubformName].Form!ControlToReferenceOnSubForm
'Forms!tbl_script_hdr!tbl_script_tests!script_test_details.Text = importString
'Form_tbl_script_details.script_test_details.Value = importString
'tbl_script_hdr!Form_tbl_script_tests.Form!script_test_details.Value = importString
'Forms![tbl_script_hdr].[tbl_script_tests].Form!script_test_details.Text = importString
Form_tbl_script_hdr.Form!Form_tbl_script_tests.Form.script_test_details.Text = importString
Re: Referring to a subform from another window
Hi,
Have you tried my code? It works for me...Ive tested it also...
:) :) :)
Re: Referring to a subform from another window
No, it gives a message saying "Object Required" - i think this is because the form is a subform, that is why i have been trying all those other variations to try and reach it...
Re: Referring to a subform from another window
Hi....
If this is a subform, try this code...
VB Code:
Me.Form_tbl_script_details.script_test_details.Value = importString
Is test_script a textbox which does not belong in the subform?
:) :) :)
Re: Referring to a subform from another window
Ok, I have a mainform which has a subform on it. A button on the subform is clicked, this opens a second form which is filtered to provide access to the records the user wants to see. test_script is a textbox on this form which contains the text of the record that the user is interested in. When the user clicks a button on this form, the text in the test_script textbox is supposed to be copied to the script_test_details textbox on the subform contained on the main form. Hope this explains it a bit better, appreciate your patience too btw!!
Re: Referring to a subform from another window
Quote:
this opens a second form which is filtered to provide access to the records the user wants to see
Hi,,
No problem, another question, whats the name of the forms?
What are the controls in the appropriate forms?
a). second form which is filtered to provide access
b). main form
c). subform
Thanks.... :) :) :)
Re: Referring to a subform from another window
Main Form: tbl_script_hdr
Subform: tbl_script_tests Subform, which access the 2nd form called frm_import_script
I found a page that seemed to describe my problem: http://support.microsoft.com/?kbid=209099
but I am still none the wiser, my latest attempt is:
VB Code:
Forms![tbl_script_hdr]![tbl_script_tests].Form!test_script_details.Text = importString
which when run says "Unable to find field tbl_script_tests, which the above mentioned page says happens when the control name is referred to incorrectly, but its not...
gnash gnash
Re: Referring to a subform from another window
MSDN Code
VB Code:
Forms![main form name]![subform control name].Form![control name]
Your Code
VB Code:
Forms![tbl_script_hdr]![tbl_script_tests].Form!test_script_details.Text = importString
Quote:
The following is the code I tried, where tbl_script_details Subform is the name of the subform
It is stated in your first post that the name of the subform is tbl_script_details..
So just substitute the subform control name to this:
VB Code:
Forms![tbl_script_hdr]![tbl_script_details].Form!test_script_details.Text = importString
Thanks.... :) :) :)
Re: Referring to a subform from another window
Thanks for trying, but access still keeps telling me it is unable to find the FIELD tbl_script_details...
Re: Referring to a subform from another window
Hey, finally it works! :)
I think it was right, but I closed Access and restarted and it and then it worked, so I must not have been saving the vbcode properly when debug. Anyway, thanks for your help!
Re: [RESOLVED]Referring to a subform from another window
Hi,,,
Quote:
I think it was right, but I closed Access and restarted and it and then it worked, so I must not have been saving the vbcode properly when debug. Anyway, thanks for your help!
Your welcome...Glad to be of service....
Please mark this thread as Resolved and Rate it if this help you....
:) :) :)