+ Reply to Thread
Results 1 to 10 of 10

Specific Picture on User Form selected from TextBox Value

  1. #1
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Specific Picture on User Form selected from TextBox Value

    I am trying to get a picture to show on a User Form based on the selection from a textbox. Any idea how to get this working right? I can get a picture to show if it was placed in the code from a list box. See sample of code below.
    Please Login or Register  to view this content.

    My problem is that the picture collection of the parts grows every week. The pictures are named with a numerical numbers and are always saved in the same folder. Is it possible to type in a certain part number inside a textbox of the user form and then have it displayed with a command button on the user form inside the image control?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Specific Picture on User Form selected from TextBox Value

    Hello Colin Smit,

    Is the folder only used for these pictures?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Specific Picture on User Form selected from TextBox Value

    Hi Leith Ross

    Quote Originally Posted by Leith Ross View Post
    Is the folder only used for these pictures?
    Yes the folder will only be used for the pictures. Each picture will be named as the part number that it represents.
    Last edited by Colin Smit; 11-01-2014 at 04:24 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Specific Picture on User Form selected from TextBox Value

    Hello Colin Smit,

    This code will load the ListBox with the file names in the folder in ascending alphabetical order (A-Z).

    You will need to change the folder path to match where your files are located.

    UserForm_Initialize Event Code
    Please Login or Register  to view this content.
    ListBox1_Click Event Code
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Specific Picture on User Form selected from TextBox Value

    I am not sure what I am doing wrong but I keep getting an error. (See attached workbook)

    Am I right in saying that the code will generate a list of all the parts in this folder? If the answer is yes.....I need to type them in manually as there will be photos of over a 1000 parts in there. To have a list to scroll trough will take up time. On the other hand the user will have the part number and could type it into the textbox. Is it possible?
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Specific Picture on User Form selected from TextBox Value

    Hello Colin Smit,

    I changed the TextBox to ComboBox. This combines the features of the ListBox and TextBox.'

    The macro is in the UserForm_Initialize event which is where it is supposed to be, not in the Submit button Click event.
    Attached Files Attached Files
    Last edited by Leith Ross; 11-02-2014 at 02:01 AM.

  7. #7
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Specific Picture on User Form selected from TextBox Value

    Quote Originally Posted by Leith Ross View Post
    Hello Colin Smit,

    I changed the TextBox to ComboBox. This combines the features of the ListBox and TextBox.'

    The macro is in the UserForm_Initialize event which is where it is supposed to be, not in the Submit button Click event.
    Thank you for that help. I now understand what I did wrong in the code. The picture now shows but only with the ListBox selection. If I type in only the part number it does not work. I see that the ListBox shows the picture selection as "C:\PartList\1990236.jpg". I presume that it does not work if I only type in the part number "1990236" because the location is not added. Is it possible to have to location added in the script so that the user only needs to type in the part number? Location will always be the same.
    Last edited by Colin Smit; 11-02-2014 at 10:00 AM.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Specific Picture on User Form selected from TextBox Value

    Hello Colin Smit,

    Here is the revised code for the UserForm. The attached workbook has all the changes included.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Specific Picture on User Form selected from TextBox Value

    Hi Leith Ross

    Thank you for the help. I will mark the thread as solved. The form works great!

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Specific Picture on User Form selected from TextBox Value

    Hello Colin Smit,

    You're welcome. I' m glad you like. If you have any questions about the code, please ask.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy an Image from a User form Picture Box to Worksheet Picture Box
    By sledgehammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2014, 11:39 AM
  2. Display selected value from the user form in a specific cell
    By vignesh805 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2013, 07:32 AM
  3. vba excel user form restrict input on user textbox
    By samz93 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2013, 04:38 PM
  4. Get the user selected text from a textbox in VBA
    By LoomisP in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-06-2012, 06:13 AM
  5. User Form Picture
    By mully in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-23-2005, 04:06 PM

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