Page 3 of 3 FirstFirst 123
Results 31 to 40 of 40
  1. #31
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    When you did the search with 2 company names in the Criteria, everything worked ok, right?


    When you do the second search, now looking for lastname, not company name, it still uses the Company name criteria?

    Your Clear_Click event code looks ok to me.

    Your BuildFilter code has this hard coded
    strSQL = "SELECT * FROM [Account List] " & _ "WHERE [Account List].[Company Name] IN(" & strCriteria & ");"
    so it's always looking for [company name]

  2. #32
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    1) Yes
    2) Yes, but does filter it more if the last name also has the same company criteria

  3. #33
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I'm not following your point #2.

    Can you save a copy of your database in mdb format--- I have access 2003 and can not open/use an accdb format database?

  4. #34
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    Has nothing selectedClick image for larger version. 

Name:	Nothing selected.JPG 
Views:	7 
Size:	104.7 KB 
ID:	9284
    Just Company selectedClick image for larger version. 

Name:	just company.JPG 
Views:	6 
Size:	97.9 KB 
ID:	9287
    Company and name selectedClick image for larger version. 

Name:	company and name.JPG 
Views:	6 
Size:	78.8 KB 
ID:	9286
    Cleared Button clickedClick image for larger version. 

Name:	cleared.JPG 
Views:	5 
Size:	78.4 KB 
ID:	9285
    just name selected no companyClick image for larger version. 

Name:	just name.JPG 
Views:	6 
Size:	72.4 KB 
ID:	9288 (this should return more data than this as I know this person has more than 2 accounts)

  5. #35
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    Let me try and make this a little bit clearer. For my Clear_Click() event, I need to know of a way to clear out the criteria from the query that was put in from the listbox. (see the pic)
    Click image for larger version. 

Name:	Capture.JPG 
Views:	9 
Size:	37.9 KB 
ID:	9298

    This is what is messing me up. This is only a problem after I choose something from my listbox.

  6. #36
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I tried mocking up a small database last night. There is a syntax error in this part of your code
    "WHERE [Account List].[Company Name] IN(" & strCriteria & ");"
    You need an extra space before the W in Where.

    Can you save a copy of your database in mdb format--- I have access 2003 and can not open/use an accdb format database?

  7. #37
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    Quote Originally Posted by orange View Post
    You need an extra space before the W in Where.
    I just tried this and it didn't have an effect on it. I no longer get the invalid code as before. I now only have the problem of removing the criteria from the query as mentioned in my last post.

  8. #38
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Is this still the Search query sql?
    In your code it was
    qdf.sql

    If so, then something is not overwriting the qdf.sql in some cases. I suggest you put some debug.print statements in and see what is the qdf.sql at various points. Step through the code as needed.

    It's hard to debug this without seeing the form/subform info and not knowing the details of the application.

  9. #39
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,
    If you are having trouble clearing a multi-select list box, here is some code to clear the selections:
    Code:
    'clear multiselect list box
    Sub ClearListBox()
       Dim theList As Control
       Dim vItem
       Dim n As Long
    
       'change "Company Name" to your list box name
       Set theList = Me("Company Name")
    
       For n = 0 To theList.ListCount
          theList.Selected(n) = False
       Next
    End Sub

  10. #40
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    215
    I want to thank everyone that provided help to me on this problem. I was able to get it to work exactly how I want. I am not quite sure what I did differently but I restarted the listbox project from the beginning and now it functions appropriately.

    Thanks again.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-22-2012, 03:28 AM
  2. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  3. Replies: 5
    Last Post: 07-13-2012, 01:15 AM
  4. Replies: 1
    Last Post: 04-20-2012, 03:16 AM
  5. Replies: 12
    Last Post: 03-22-2012, 02:48 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