Results 1 to 4 of 4

Focus from listbox selection to textbox gives an error

Threaded View

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    Serbia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Focus from listbox selection to textbox gives an error

    I have a textbox3 for input value, and based on that value, if exist/correct focus is set on next textbox(12) if not listbox is populated with all values from a column (named range) and most similar value with that in textbox3 is selected in listbox.

    After correct value is selected listbox can not unfocus. Every attempt to focus to any other object results in this error (Run-time error -2147467259 (80004005) Unspecified error).

    And here is the code :

    Private Sub TextBox3_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    
    Dim ws As Worksheet
    Set ws = Sheets("INPUT")
    
    If ws.Range("G3").Value = 0 Then
    Label7.Caption = "This value does not exist"
    
    
    
            ListBox1.List = [KUP].Value ' NAMED RANGE
    
    ListBox1.Value = ws.Range("G5").Value ' SELECTS MOST SIMILAR VALUE 
    
    Else
    End If
    End Sub
    And

    Private Sub ListBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii = 13 Then 'KeyCode
    
    TextBox3.Value = ListBox1.Value
    Cancel = False ' tried with or without ... no change
    TextBox12.SetFocus ' THIS ONE GIVES AN ERROR
    
    End If
    
    End Sub
    I've tried every combination that crossed my mind and everything resulted in same Unspecified error.
    Last edited by Jovica; 03-23-2014 at 05:54 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] UserForm - How To Make TextBox Value Change Depending On ListBox Selection
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2013, 05:05 PM
  2. [SOLVED] Textbox focus
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-08-2013, 12:25 AM
  3. Multi select Listbox Items selection based on other Listbox item selection.
    By srinivassathi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 05:53 AM
  4. Textbox update with previous selection from listbox
    By Binsy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2010, 05:03 PM
  5. Retaining focus on a textbox / listbox item pair after validation = false.
    By chatterbox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2006, 06:50 AM

Tags for this Thread

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