|
-
Mar 2nd, 2006, 09:34 PM
#1
Thread Starter
Member
[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
Last edited by Santos7772005; Mar 7th, 2006 at 03:55 PM.
Reason: Resolved
-
Mar 3rd, 2006, 12:07 AM
#2
Re: 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.
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)?
-
Mar 5th, 2006, 02:38 PM
#3
Thread Starter
Member
Re: Referring to a subform from another window
 Originally Posted by KGComputers
Thats correct, yes.
-
Mar 5th, 2006, 09:30 PM
#4
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
-
Mar 5th, 2006, 11:01 PM
#5
Thread Starter
Member
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
-
Mar 5th, 2006, 11:20 PM
#6
-
Mar 6th, 2006, 02:24 PM
#7
Thread Starter
Member
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...
-
Mar 6th, 2006, 08:39 PM
#8
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?
-
Mar 6th, 2006, 09:40 PM
#9
Thread Starter
Member
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!!
-
Mar 6th, 2006, 10:15 PM
#10
Re: Referring to a subform from another window
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....
Last edited by KGComputers; Mar 6th, 2006 at 10:27 PM.
-
Mar 6th, 2006, 11:14 PM
#11
Thread Starter
Member
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
-
Mar 6th, 2006, 11:59 PM
#12
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
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....
-
Mar 7th, 2006, 03:07 PM
#13
Thread Starter
Member
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...
-
Mar 7th, 2006, 03:53 PM
#14
Thread Starter
Member
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!
-
Mar 7th, 2006, 10:13 PM
#15
Re: [RESOLVED]Referring to a subform from another window
Hi,,,
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....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|