Results 1 to 8 of 8
  1. #1
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52

    Unable to search record in my listbox

    I have a form with an unbound textbox (txtSearch) and a listbox (myList). I modified the row source in my listbox to accomplish a union query. The new feature gives me the ability to select a record in my listbox then it would display the results in a query table. However the search feature no longer works.



    Previous Codes:
    myList rowsource:
    Code:
    SELECT tablename.fielname1, tablename.fielname2, tablename.fielname3,tablename.fielname4
    Criteria:
    Code:
    Like [Forms]![frmName]![txtSearch] & "*"
    textbox code:
    Code:
    Private Sub txtSearch_Change()
    Me.myList.Requery
    Me.Refresh
    Me.txtSearch.SelStart = Me.txtSearch.SelLength
    End Sub
    myList New rowsourcecodes:
    Code:
    SELECT DISTINCT tablename.fieldname1,tablename.fieldname2,tablename.fieldname3 FROM tablename UNION select tablename.fieldname1,tablename.fieldname2,tablename.fieldname3;
    I also created a command button (on_Click) to general the results in a query table.

    Help..

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you post an example of your database? It's going to be difficult to track this problem down without seeing it.

  3. #3
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    Please see attached sample DB

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I can't read accdb's at my current location. if possible could you upload a 2003 version (your profile says access 2002 so I didn't think to ask this first)

  5. #5
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    I uploaded the wrong DB..be back in a minute

  6. #6
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    here it is..

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Ok this may be the problem:

    in the ON CHANGE property of your txtSearch field you have some other code along with these two lines:

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

    Is the problem that the database does not function in Access 2007+?

    If so it's because all of the menus were changed to 'ribbons' and the domenuitems are probably not going to work. I'm not entirely sure what you're trying to do with your tables, I can't really understand what's going on with them but if it's specifically the searching function it's a very safe bet that these two lines are causing you the problem.

    Are you trying to populate the list box with only those items that match your criteria in the txtsearch? if so it's a relatively easy fix

  8. #8
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    I did some revisions on my project DB, I just realized that I don't need an extra command button to display results based from a selected record in my listbox. I used the DblClick event in my listbox to get it working. My txtSearch is now working also. One more thing, my computer got upgraded to MS Office 2010 and I'll be doing future editing in the new version.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unable to add a record on a form
    By JamiB1979 in forum Forms
    Replies: 1
    Last Post: 06-22-2011, 08:36 PM
  2. Identical record in a Listbox
    By mar_t in forum Access
    Replies: 4
    Last Post: 05-26-2011, 08:30 PM
  3. Unable to create new record in Forms
    By escapades_access in forum Forms
    Replies: 5
    Last Post: 03-16-2011, 03:23 PM
  4. Navigate to a record in a listbox
    By jackkent in forum Access
    Replies: 4
    Last Post: 10-03-2010, 09:36 AM
  5. unable to add new record
    By itsmemike in forum Forms
    Replies: 2
    Last Post: 08-24-2010, 04:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums