+ Reply to Thread
Results 1 to 9 of 9

Call a function on another form and passing a string

  1. #1
    Registered User
    Join Date
    03-12-2009
    Location
    Breda, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    27

    Call a function on another form and passing a string

    Hello,

    I have two userforms on one I make a selection which comes in a textbox

    If I press a button I want too call a function on the other userform and pass that String soo I can use it in the other Userform.

    Is this possible?

    I tried too do it, but i'm getting an error 438 the methode is not supported.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Call a function on another form and passing a string

    There are various ways of doing this.

    Public variable
    priviate property on 2nd userform
    reading the information from the 1st userform

    Can you post what you currently have
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-12-2009
    Location
    Breda, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Call a function on another form and passing a string

    Hello,

    I Have two forms a main form called Mainfrm in which i have

    Please Login or Register  to view this content.
    Then a form called Selectservers

    I have a textbox called Selectedserver from which I want too use the string too pass it too my mainform.

    I have a button called Connect

    Please Login or Register  to view this content.
    He gives an error on fMainForm.AddSelected Selectedserver.Text I tried using call but that doesn't work also.

    As can be seen their is more on both forms but as in my previous thread you can't use that code because of a missing dll.

    I now also have a Module1 added in which i make my mainform public or atleast i try too....

    Please Login or Register  to view this content.
    After I added the module1 I got a different error namely error 91 that the with statement isn't specified.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Call a function on another form and passing a string

    Here is a generic example that uses a Property to populate the label on userform2

    Module1 code
    Please Login or Register  to view this content.
    Userform1 - Textbox and commandbutton
    Please Login or Register  to view this content.
    Userform2 - label and commandbutton
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-12-2009
    Location
    Breda, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Call a function on another form and passing a string

    Hello,

    Thank you for your reply.

    This could solve my problem, but their isn't a way too pass a string too a sub in a userform soo I can use it their? With the label should work but the way i described should be possible also it's just I can't find a lot about it or i'm looking for the wrong things with google

    greetings

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Call a function on another form and passing a string

    If your really must use a Sub then it would be

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-12-2009
    Location
    Breda, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Call a function on another form and passing a string

    Hello,

    Now i'm getting a compile error The argument isn't optional on .SetText in the code.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Call a function on another form and passing a string

    Because that is not how you call a sub.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-12-2009
    Location
    Breda, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Call a function on another form and passing a string

    Hmmm,

    How could I have missed that sigh. And your right that solved the problem

    thank you.

    greetings

    Hmmmm i try too call a sub that needs too be done after I add that string too the label on the mainform and then the error comes back sigh. this is getting annoying haha, but now I really want too get it too work. Is their somewere a good tutorial on this passing business I think I need too research the topic a bit better since i'm getting a lot of errors.
    Last edited by dadio25; 03-17-2009 at 10:37 AM. Reason: another error

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1