Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58

    searching forms, subforms and combo boxes

    Hi there,

    Question 1


    I am referring to this great resource for building search boxes: http://www.access-programmers.co.uk/...d.php?t=188663
    and so far the demo search box for my own database is working well, however, I don't know how to get the record I've selected to populate in my form.
    If i double click on the record I want (as John Big Booty suggests) it doesn't bring it up.

    Question 2
    THis relates to combo boxes AND subforms.

    My contacts database has many combo boxes, and a subform. How do I make it easy for my users to search them all? I would like it to be possible to search every field. In particular, I have a subform on my main form that holds my addresses. Is it possible to search this in the above search?

    If not, can I create another search box on my main form to search the subform? I've done some research on the internet about this, but so far I haven't had much luck finding an answer (that I completely understand!)

    I feel like I'm missing something with subforms/combo boxes...why is it so hard to search them??

    Note: Filtering is a little tricky for my users as they are using Access for the first time, so I'd prefer it if it were simple like Control-F or a simple search box. (besides, you can't filter combo boxes, can you?)


    Apologies if there are a lot of questions here. If anyone has any ideas, I'd be grateful,

    Thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Maybe these will help

    http://datapigtechnologies.com/flash...tomfilter.html

    http://datapigtechnologies.com/flash...earchform.html

    Yes, combobox RowSource can be a filtered query.

    http://datapigtechnologies.com/flash...combobox2.html

    For the double-click to work, need code in the form DblClick event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    Thank you, these videos are really helpful.

    I'm still wondering if it's possible to create a keyword search? (I don't think that was covered in these videos) I'm guessing it requires a lot of coding.

    For example, in my company search box, not having a keyword option proves to be a problem with names such as Centre Pompidou, or The Museum of Medical History, where the user must remember the first word to find the right institution/company name. I'd prefer to avoid this sort of trial and error.

    Thanks.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Use wildcard at begin and end of parameter:

    LIKE "*" & forms!formname!controlname & "*"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    Thanks, I just realized this!
    I created a demo of my search form, and it works well, except it doesn't generate ALL my records. Some contacts don't appear...but I can't work out why.
    It seems only about 2/3 of my contact list comes up when I run the query.

    I've attached the query here.Click image for larger version. 

Name:	SnipQuery.JPG 
Views:	35 
Size:	86.6 KB 
ID:	11347

  6. #6
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    If this helps:

    It doesn't seem to display many contacts who are non USA -only two or three come up. About 500-600 contacts from all over the rest of the world should come up, but don't, for some reason.

    (by the way, I capitalised Country in my query field box, and it didn't make any difference)

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Access is not case sensitive so 'country' is equivalent to 'Country'.

    Don't know why the non-USA issue. Would have to analyze data. If you want to provide, follow instructions at bottom of my post.

    Your search results will not work right if fields are allowed to be null. Need to handle that by creating fields with expression and apply the filter parameters to constructed field. For instance, if Street3 can have null:

    Street3Adj: Nz([Street3],"")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    I seem to have resolved the problem, I took another query that was working correctly and amended it, and it's fine now.

    Do I enter the info: Street3Adj: Nz([Street3],"") to the query in the criteria section? For each field?
    So far my results seem good without this. Even if I have empty fields, they're coming up in the search.

    One more thing, I wanted to have a combo box on my form to *just* search contact name, however, some of my Last Name entries actually have two names: the surname of the main contact and the name of the spouse ie.

    First Name: Matthew
    Last Name: Andrews and Ms. Holly Oaks

    I have added LIKE "*" & forms!formname!controlname & "*" into my Last Name field of my combo box, but it doesn't seem to be searching the whole last name, just the first part. So if I search for Oaks, it doesn't come up.

    If it doesn't work it doesn't really matter, I can make do!
    Here is the query. ComboBox 78 is the combo box name for the search box, the form name is the name of the main form where the combo box resides.

    Click image for larger version. 

Name:	LastName.JPG 
Views:	33 
Size:	60.7 KB 
ID:	11363

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Street3Adj: Nz([Street3],"") is not criteria, it is a constructed field. Apply criteria to that constructed field. But if is working without, disregard.

    A string is a string regardless of how many names are in it. I don't understand why LastName search for *Oaks* doesn't work.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    Hi there,
    I am thinking about your recommendation to use Street3Adj: Nz([Street3],"")
    I might need to use if for another query...can you explain what it does? (And what does the Adj mean exactly)?

  11. #11
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    To re-phrase my problem: I have two subforms on my form and it looks like my query is not bringing back results if any of my contacts have either or both of the subforms blank (one subform is for addresses, and the other is for categories). I'm not sure how to fix this.
    My query is fairly complex and searches a number of different tables. Perhaps this is the problem?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Street3Adj is just a name I gave the constructed field. Adj is abbreviation of adjusted. Use whatever name suits you.

    Nz is an intrinsic function, review http://office.microsoft.com/en-us/ac...001228890.aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    Thanks for this. I've added it to my query for most of the fields.
    Did you notice my other post? about having problems retrieving records where the address or category fields are blank?
    I've added the constructed field you mentioned to make sure it brings back these records even if these fields are null.... but it's not working.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Isn't that why I suggeted the Nz function and constructed field?

    Did you apply the filter criteria under the constructed field?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    pbouk is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    58
    Hi there,
    I would prefer not to attach this database to a public forum, but I could send to you personally.
    I have put this Nz function in the database, you'll see it included the query below (in two halves). It doesn't seem to be working though. As I said, there are some records that are not being retrieved because they either don't have an address or a category or both. I added the Nz thing to the address type description (as this is always filled if there is an address), but should I add it to all the address fields?

    Click image for larger version. 

Name:	searchmulti1.PNG 
Views:	11 
Size:	44.0 KB 
ID:	11584

    Click image for larger version. 

Name:	Searchmulti2.jpg 
Views:	10 
Size:	72.7 KB 
ID:	11585

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. cascade combo boxes in continous forms
    By storm1954 in forum Forms
    Replies: 3
    Last Post: 05-10-2012, 06:00 AM
  2. Replies: 5
    Last Post: 01-18-2012, 12:18 AM
  3. Replies: 13
    Last Post: 11-17-2011, 01:39 AM
  4. cascading combo boxes on Continuous Forms
    By Jerry8989 in forum Forms
    Replies: 0
    Last Post: 10-12-2009, 10:02 AM
  5. Help with Subforms/Combo Boxes
    By mikel in forum Forms
    Replies: 11
    Last Post: 06-03-2009, 07:45 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