+ Reply to Thread
Results 1 to 6 of 6

Auto Refresh Listview table after Keydown event VBA, Yelp!

  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    Surabaya, Indonesia
    MS-Off Ver
    MS 365 (Windows 11 64-bit)
    Posts
    84

    Auto Refresh Listview table after Keydown event VBA, Yelp!

    Hi all,

    Help me please, I don't know whats wrong with the code. I attach my file, if you need to review the code.

    I'm working with listview here. I use dummy data, to make it more simpler. I want my listview autorefresh whenever i press F1 (to refer to 2nd database), and F2 (to refer back to 1st database), the default need to show 1st database

    see below pic, table B5:D25 (beige), is the 1st database. and G5:I16 (blue) is the 2nd database

    Listview.JPG

    I want to show the listview listitems, like this

    if G1 (yellow) was blank, indicated by H1 (istext = false), then

    show 1st database

    else G1 (yellow) was filled, indicated by H1 (istext = true)

    show 2nd database
    and here's my current code,

    telling if
    press F1, selection item will be copied to G1 - Listview gonna refreshed and showed 2nd database.
    press F2, content/text in G1 will be deleted - listview gonna refreshed and showed 1st database

    currently
    1. when first time running, 1st database wasn't showed, press alt/shift/ctrl will showed them

    2. the listview not immediately refreshed after press F1, need to press alt/shift/ctrl to refresh

    3. the listview not immediately refreshed after press F2, need to press alt/shift/ctrl to refresh

    4. i can't use up/down key direction to select within the listview.
    Please Login or Register  to view this content.
    Mucho gracias,
    Thanks a lot for the help

  2. #2
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Auto Refresh Listview table after Keydown event VBA, Yelp!

    Hi radian,

    Find attached the workbook with working code.
    i will try to explain the changes

    1. you could not use up/down key to navigate cause that is a keydown event and triggered this part which loaded table 1 or 2 again
    Please Login or Register  to view this content.
    2. I added the call of table 1 in the initialize of the form so it gets shown immidiately

    3. i removed this part
    Please Login or Register  to view this content.
    and added the call for table1 and two directly in the if section of f1 and f2 key. and then replaced the exit sub part in the F1 section with exit for

  3. #3
    Registered User
    Join Date
    11-12-2015
    Location
    Surabaya, Indonesia
    MS-Off Ver
    MS 365 (Windows 11 64-bit)
    Posts
    84

    Re: Auto Refresh Listview table after Keydown event VBA, Yelp!

    Quote Originally Posted by LordLoki View Post
    Hi radian,

    Find attached the workbook with working code.
    i will try to explain the changes

    1. you could not use up/down key to navigate cause that is a keydown event and triggered this part which loaded table 1 or 2 again
    Please Login or Register  to view this content.
    2. I added the call of table 1 in the initialize of the form so it gets shown immidiately

    3. i removed this part
    Please Login or Register  to view this content.
    and added the call for table1 and two directly in the if section of f1 and f2 key. and then replaced the exit sub part in the F1 section with exit for
    Hi LordLoki,

    sorry for late reply, i don't receive email for your reply to my thread,
    It's work! and awesome, i don't know it would be this simple :D

    thanks a lot so much, you made my day
    regards

  4. #4
    Registered User
    Join Date
    11-12-2015
    Location
    Surabaya, Indonesia
    MS-Off Ver
    MS 365 (Windows 11 64-bit)
    Posts
    84

    Re: Auto Refresh Listview table after Keydown event VBA, Yelp!

    Quote Originally Posted by LordLoki View Post
    Hi radian,

    Find attached the workbook with working code.
    i will try to explain the changes

    1. you could not use up/down key to navigate cause that is a keydown event and triggered this part which loaded table 1 or 2 again
    Please Login or Register  to view this content.
    2. I added the call of table 1 in the initialize of the form so it gets shown immidiately

    3. i removed this part
    Please Login or Register  to view this content.
    and added the call for table1 and two directly in the if section of f1 and f2 key. and then replaced the exit sub part in the F1 section with exit for
    Hi Loki,

    sorry, I had another problem coming, and it's similar when you added exit for in the code.

    I made my userform floating when the file open with

    Please Login or Register  to view this content.
    but, when i press F1 it didn't show the tabel2 (i change your code, when press F1 will call tabel2), instead I need to press ctrl or alt or shift + F1 to made it happen.

    can you help me figure the logic? I attached the file

    listview call macro to display different table .xlsm

    thanks a lot for the 2nd help

  5. #5
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Auto Refresh Listview table after Keydown event VBA, Yelp!

    Hi Radian,

    Apperently the F1 Key does not trigger the keydown event when the Window is modeless
    Just change F1 to F3 or another key then it should do just fine.

    Greets
    Loki

  6. #6
    Registered User
    Join Date
    11-12-2015
    Location
    Surabaya, Indonesia
    MS-Off Ver
    MS 365 (Windows 11 64-bit)
    Posts
    84

    Re: Auto Refresh Listview table after Keydown event VBA, Yelp!

    Quote Originally Posted by LordLoki View Post
    Hi Radian,

    Apperently the F1 Key does not trigger the keydown event when the Window is modeless
    Just change F1 to F3 or another key then it should do just fine.

    Greets
    Loki
    Hi LordLoki

    well NOTED, just tried with F7, and it works just fine... thanks a lot for the help

+ 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. InkEdit Keydown Event (VBA Excel)
    By ibreno in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2015, 05:31 PM
  2. Auto-refresh pivot tables in worksheet_change event?
    By 1eyedjack in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-01-2012, 03:00 PM
  3. import data from access table to excel pivot table - Enable Auto Refresh
    By okl in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-01-2010, 09:38 AM
  4. Event keypress, tab or keydown and Setfocus
    By antoni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2009, 10:55 PM
  5. Textbox Keydown event not triggered.
    By droopy928gt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 09:52 AM
  6. [SOLVED] Can I detect a KEYDOWN event while in a worksheet
    By Ken Soenen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2005, 09:20 PM
  7. keydown event
    By bfa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2005, 10:06 AM

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