+ Reply to Thread
Results 1 to 23 of 23

VBA userform search and update

  1. #1
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    VBA userform search and update

    Hi Guys,

    I'm looking for some help with the following please ..

    I have a simple cashier system i'm using to improve my vba attached ( with the help of this forum)

    My issue is on the edit_trans userform

    So Far it when a user inputs the member name and it fills in the membership number

    I need to use the transaction date (user inputted) together with either the name or membership number to pull back the matching transaction from the 'transactions detail' sheet so the user can update incorrect detail

    so far I have this ... but it only refs the 1 textbox and this doesn't even work

    Please Login or Register  to view this content.
    can anyone help please ?

    Thanks
    Sazza
    Attached Files Attached Files
    Last edited by Sazza; 12-13-2016 at 09:44 AM.

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: VBA userform search and update

    Hi Sazza, I looked but did not see edit/trans userform

  3. #3
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: VBA userform search and update

    Try this code for "Search Trans" button
    Please Login or Register  to view this content.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: VBA userform search and update

    I'd do something like below. It would be faster, if transaction list becomes large.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    Thanks CK76 - that's works perfectly - Thanks a mill

  6. #6
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    Sorry nigelog I haven't assigned it a button a yet - getting ahead of myself

  7. #7
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    Thanks Kasan

  8. #8
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    CK76 - How do I write out any changes using your array ?

    I was using
    Please Login or Register  to view this content.

  9. #9
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: VBA userform search and update

    I looked at it quickly and just had a thought that you would need to know the exact date which is restrictive. If you could get the search transaction button to return all records for the member, from a date, to a listbox and use a double_click event to open the details in a userform and record any changes back to the transaction overview sheet. I got round a similar problem recently by this method and didn't take much extra work......

  10. #10
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    I was thinking the same thing tbh but as im only learning I will try get my head around this exact date way first then tackle the lsitbox method ..

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: VBA userform search and update

    CK76 - How do I write out any changes using your array ?
    You'd store "i" when record is found, and use that to return info to sheet.

    So if record is found when "i" is 5. You'd add 1 (offset for header row) to that, meaning 6 is the row number of the cell you need to return data to.

    By the way, how large would you imagine entire record set would be (i.e. max # of rows). And would transaction date be unique list for each individual (i.e. 1 transaction per day per individual) or could there be more than 1 per individual?

  12. #12
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    not overly large CK76... but I hadn't taken account for multiple transactions per pers on the same date ... there could be many trans ...

    i'll give your suggestion a go ... thanks again

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA userform search and update

    OK, babysteps.
    This one is to test Search function. First select name then fill Transaction date. Click Search Trans.
    Listbox is filled with results. DoubleClick a ListBox result fills remaining TextBoxes.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  14. #14
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    ah bakerman2 its been awhile and im still plugging away at this ...

    your version as always works perfectly and as always confuses the bejaysus out of me with loops

  15. #15
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: VBA userform search and update

    hadn't seen Bakermans posted but added to it. Now updates entries and refreshes listbox entries so user can see changes made on userform
    Attached Files Attached Files
    Last edited by nigelog; 12-14-2016 at 10:08 AM.

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA userform search and update

    @ nigelog

    The risk of duplicate numbers is too big to add numbers like that.
    The way I solved it is to assign the row numbers of each transaction on runtime ie when loading Listbox.
    Further explenation is added to code.

    @ Sazza

    Test it out and let us know.
    Attached Files Attached Files

  17. #17
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: VBA userform search and update

    Quote Originally Posted by bakerman2 View Post
    @ nigelog

    The risk of duplicate numbers is too big to add numbers like that.
    The way I solved it is to assign the row numbers of each transaction on runtime ie when loading Listbox.
    Further explenation is added to code.

    @ Sazza

    Test it out and let us know.
    had just done the same lol as a quiet day....

  18. #18
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    Hi Bakerman2 - ( edit now I see your response above)

    Thanks again

    I hadn't come across .tag yet ...
    Last edited by Sazza; 12-14-2016 at 09:09 AM.

  19. #19
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA userform search and update

    You're welcome and thanks for adding rep points.

  20. #20
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA userform search and update

    one last question - sorry ...

    I was running through what I / we have already and have discovered a bit of an anomaly ..

    if I add more than 4 transactions the 'Transactions Summary' tab goes a bit mad - row 5 gets hidden and the details start going into the same row as the previous transaction.

    I've let the attached in the state im trying to explain
    Attached Files Attached Files

  21. #21
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: VBA userform search and update

    I saw the missing line so can only assume something was carried over when you made an entry. I deleted Tran Sum worksheet and created a new one and seems fine. Ive gone past 5 entries anyway.
    Attached Files Attached Files
    Last edited by nigelog; 12-14-2016 at 01:16 PM.

  22. #22
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA userform search and update

    There was some kind of filter still active being the reason row 5 was hidden and the sheet was acting up.
    Deleting the sheet and creating a new one like nigelog did was one of the options to clear everything. (clearing the filter like I did was another option)

  23. #23
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286
    @bakerman
    In the last file i uploaded i used the unique entry number to refresh the userform after an edit so you could see entry immediately. Can the tag be used to the same effect to rewrite and refresh listbox??

+ 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. [SOLVED] Delete/Update/Add/Search records in userform
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-15-2016, 04:20 PM
  2. userform search and update
    By adamheon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2016, 02:13 AM
  3. [SOLVED] VBA Userform - Search, Edit & Update functionality
    By camp2chiawa in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-15-2016, 03:43 AM
  4. Doing search and update in workbook with userform
    By jhinruiz28 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-04-2015, 03:13 AM
  5. On Userform, how to put Search, Delete, Add, Update buttons
    By TSHEPO19811 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-07-2015, 10:38 AM
  6. Userform ADD/SEARCH/UPDATE Features
    By BARENTINEMATT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2015, 11:55 AM
  7. Get Userform with search and Update functions to work
    By aemden1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2014, 12:18 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