+ Reply to Thread
Results 1 to 11 of 11

1 Userform that searches and display data in another userform

  1. #1
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    1 Userform that searches and display data in another userform

    Hi.

    i am new to VBA and thus i appreciate any help in solving my issue.

    So basically i am trying to develop a tracking program where by there are 2 userforms, ShipmentTracking and frmDisplay. A user will only need to input his name and card.no(Only last 4 digits) in the form ShipmentTracking, clicks the Enter button and it will search for corresponding data in the worksheet and then display the rest of the customer details in the 2nd userform, frmDisplay. And also when frmDisplay shows ShipmentTracking will be hidden/closed. I have no clue in how to start developing such codes so any help in getting started will be truly appreciated!

    Thanks in advance!
    Last edited by Mystojam; 03-11-2013 at 12:24 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1 Userform that searches and display data in another userform

    Is there a reason for using 2 userforms?

    This could all fit on one form which would simplify things a lot.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: 1 Userform that searches and display data in another userform

    I'm with Norie on this one, a single userform should be used
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: 1 Userform that searches and display data in another userform

    Hmm.. there's no definite reason actually. I just thought maybe it will seem more neat or something. but is it possible to have 2? And okay if i were to use only 1 form what are the necessary changes?

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: 1 Userform that searches and display data in another userform

    Mystojam,

    It depends on what you want the form to do. Do you want it to only show existing information? Should users also be able to make changes to that information through the form? Should the form be able to delete existing records and/or create new records?

  6. #6
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: 1 Userform that searches and display data in another userform

    Only show the existing details through the form. No changes of information and adding and deleting of records through the form. My apologies for not being clear about this. Preferred if the information displayed are through textboxes or labels like in the 2nd form

  7. #7
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: 1 Userform that searches and display data in another userform

    Here's the edited userform do let me know if i am still missing anything
    Last edited by Mystojam; 03-11-2013 at 12:26 AM.

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: 1 Userform that searches and display data in another userform

    Mystojam,

    Attached is a modified version of your workbook. Here is the code I used for the "Enter" button:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: 1 Userform that searches and display data in another userform

    tigeravatar,

    Oh man thanks a bunch! I just have to make some slight changes but ultimately this is what i wanted. Though now i just called my supervisor to clarify and he wants 2 userforms instead of 1. He wants the results to display on the 2nd form. So if its the case will there be any much changes to the code?

    Mystojam

  10. #10
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: 1 Userform that searches and display data in another userform

    Mystojam,

    The searchng code would all stay the same, except the use of the "Me." part. Instead of that, you would use the name of the second userform. After the search is done, you would do Me.Hide (hides userform1) and UserForm2.Show (displays the second userform).
    Also, the button on the worksheet that displays the first userform should be like this:
    Please Login or Register  to view this content.

    You would also want to update UserForm2's queryclose event so that if someone presses the X in the upper right, it only hides the userform instead of unloads it. Then in UserForm1's terminate event and Close/Exit button, you'll want to have both Unload UserFormX lines

  11. #11
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: 1 Userform that searches and display data in another userform

    tigeravatar,

    It's working perfectly now. Thank you so much for all your attention and help. Words can't describe the kind of gratitude i have. You will be blessed!

    Mystojam

+ 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