Results 1 to 15 of 15

Thread: [RESOLVED]Referring to a subform from another window

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    [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

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    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)?


  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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.

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Referring to a subform from another window

    Try this one and let me know...


    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim importString As String
    3.    
    4.     test_script.SetFocus
    5.     importString = test_script.Value
    6.    
    7.     Form_tbl_script_details.script_test_details.Value = importString
    8.  
    9. End Sub


  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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:
    1. Dim importString As String
    2.    
    3.     test_script.SetFocus
    4.     importString = test_script.Text
    5.    
    6. '[forms]![MainFormName]![SubformName].Form!ControlToReferenceOnSubForm
    7. 'Forms!tbl_script_hdr!tbl_script_tests!script_test_details.Text = importString
    8. 'Form_tbl_script_details.script_test_details.Value = importString
    9. 'tbl_script_hdr!Form_tbl_script_tests.Form!script_test_details.Value = importString
    10. 'Forms![tbl_script_hdr].[tbl_script_tests].Form!script_test_details.Text = importString
    11.  
    12.     Form_tbl_script_hdr.Form!Form_tbl_script_tests.Form.script_test_details.Text = importString

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Referring to a subform from another window

    Hi,

    Have you tried my code? It works for me...Ive tested it also...


  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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...

  8. #8
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Referring to a subform from another window

    Hi....

    If this is a subform, try this code...

    VB Code:
    1. Me.Form_tbl_script_details.script_test_details.Value = importString

    Is test_script a textbox which does not belong in the subform?

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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!!

  10. #10
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    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.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  11. #11

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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:
    1. 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

  12. #12
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Referring to a subform from another window

    MSDN Code
    VB Code:
    1. Forms![main form name]![subform control name].Form![control name]

    Your Code

    VB Code:
    1. 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:
    1. Forms![tbl_script_hdr]![tbl_script_details].Form!test_script_details.Text = importString


    Thanks....
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  13. #13

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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...

  14. #14

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    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!

  15. #15
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    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....


    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width