+ Reply to Thread
Results 1 to 10 of 10

Userform Search Criteria

  1. #1
    Forum Contributor
    Join Date
    08-07-2008
    Location
    Australia
    Posts
    132

    Userform Search Criteria

    Does anyone know what code I can use to reflect the Find search to cater for multiple text lookup options in the userform?

    For example, the current code (cmbFind_Click) caters for find lookup on one text box only (txtDesLcn), however I would also like the oppotunity to use the search criteria for "txtSerial" as well. e.g. tupe in the Serial number and click "Find" to display the rest of the fields in the userform from the Database.

    I was thinking

    Please Login or Register  to view this content.
    This however doesn't work. Please refer to attached spreadsheet for code.

    Thanks in advance for your help!!!
    Attached Files Attached Files

  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,258

    Re: Userform Search Criteria

    Hello timarcarze,

    I updated your macro to find either the location or the serial number. The macro below has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    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
    08-07-2008
    Location
    Australia
    Posts
    132

    Re: Userform Search Criteria

    Quote Originally Posted by Leith Ross View Post
    Hello timarcarze,

    I updated your macro to find either the location or the serial number.
    Hi Leith,

    Thanks for your assistance. This seems to mainly work, however I noticed 2 bugs on two seperate searches:

    (1) It fell over when I attempted to search a 'location' which had multiple copies of the location e.g. Test (type in "Test" in location and it brings across wrong data).

    (2) I also populated a number in serial number, .e.g. 123 and then tried to search "123" in serial number text box. The search came back with "found 10 copies", however 123 was a string from other columns in the datacase rather than specifically looking for the number 123 in "Serial Number" column.

    Hope you can help.

  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,258

    Re: Userform Search Criteria

    Hello timarcarze,

    I have fixed the first issue and second one partially. The forward and backward buttons do not return the proper data from the Find list. I will have to look more closely at the code to find all the problems. Here is the updated macro which has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-07-2008
    Location
    Australia
    Posts
    132

    Re: Userform Search Criteria

    Quote Originally Posted by Leith Ross View Post
    Hello timarcarze,

    I have fixed the first issue and second one partially. The forward and backward buttons do not return the proper data from the Find list. I will have to look more closely at the code to find all the problems. Here is the updated macro which has been added to the attached workbook.
    Thanks Leith, that's great! I see your point about the small error with the start and end buttons.

    If you wouldn't mind, would be great if you could point out how to resolve the border creation on adding a new entry, per my other post: http://www.excelforum.com/excel-prog...row-added.html

    Thanks again for spending the time. Is a real hand for us newbies coming to grips with VBA.

  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,258

    Re: Userform Search Criteria

    Hello timarcarze,

    The attached workbook has been revised. Try it and let me know if any changes need to be made.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-07-2008
    Location
    Australia
    Posts
    132

    Re: Userform Search Criteria

    Quote Originally Posted by Leith Ross View Post
    Hello timarcarze,

    The attached workbook has been revised. Try it and let me know if any changes need to be made.
    Hi Leith,

    I have just uncovered one other bug with the "find" and "amend" functionality, and am unable to fix it.

    You have set it up so that we can search ("Find") by 2 criteria, (1) Despatch Location and (2) Serial No. Despatch Location works fine when you search by Despatch Location, however the problem lies with the Serial No. The steps to trace the error are as follows:

    1. Add a new record completing the fields up to and including the serial No, e.g. Serial No = 12345.
    2. Exit Userform
    3. Open userform and enter serial number 12345 and click Find.
    4. It brings up the data ok, but when you complete the blank fields and click "Amend", the data is populated commencing at the serial no field and do not line up with their corresponding field names?

    I presume this would need an If Function of some sort that would cover the 2 "Find" scenarios listed above. Appreciate if you could help me out on this one.

  8. #8
    Forum Contributor
    Join Date
    08-07-2008
    Location
    Australia
    Posts
    132

    Re: Userform Search Criteria

    Quote Originally Posted by timarcarze View Post
    Hi Leith,

    I have just uncovered one other bug with the "find" and "amend" functionality, and am unable to fix it.

    You have set it up so that we can search ("Find") by 2 criteria, (1) Despatch Location and (2) Serial No. Despatch Location works fine when you search by Despatch Location, however the problem lies with the Serial No. The steps to trace the error are as follows:

    1. Add a new record completing the fields up to and including the serial No, e.g. Serial No = 12345.
    2. Exit Userform
    3. Open userform and enter serial number 12345 and click Find.
    4. It brings up the data ok, but when you complete the blank fields and click "Amend", the data is populated commencing at the serial no field and do not line up with their corresponding field names?

    I presume this would need an If Function of some sort that would cover the 2 "Find" scenarios listed above. Appreciate if you could help me out on this one.
    Can anyone assist with the above query? I believe it has something to do with the "Activecell" reference in the Click_Amend Macro, however not sure how to fix it??? Help appreciated.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform Search Criteria

    The amend code is not working because the Rng variable has not been assigned a value. I'll need to see what has been changed from the original code
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  10. #10
    Forum Contributor
    Join Date
    08-07-2008
    Location
    Australia
    Posts
    132

    Re: Userform Search Criteria

    Guys,

    I received some help from another site on this last part only (http://www.ozgrid.com/forum/showthre...goto=newpost**). The code received was:

    Please Login or Register  to view this content.
    This seems to have fixed the Amend/Find issue when searching via "Serial No".

    Thanks for your help

+ 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