Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    Nested Search???

    Hi

    back froms holidays and back on the database.

    I now have the tables, relationships set up and (with help) have a query to display all records and I have created a basic form based on the query to search for a record.

    But - ok there's always a but!

    It's not searching as I want and I'm not sure what to call the search method I want to get help via google etc.

    Simply the database contains a list of graves in a cemetery which includes names and years and various other data.

    I want a search where if I search for Smith the all the Smiths are displayed in table format ie one per line just showing name, year of death, first name, year of birth

    I then want the facility for the user to click on a record/line and have the full details revealed in a popup form or possible in another tab.

    Can someone point me in the right direction



    thanks

    Ian

  2. #2
    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,726
    Ian,

    Take a look at the Modified Universal Search database I supplied to the Code Repository.
    You could make a copy of that database; remove all of the tables; link your tables that you want to search;
    use the form and follow the directions.

    https://www.accessforums.net/code-re...rch-43055.html

    You could just look at the databases event procedure codes and build your own.

  3. #3
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Thanks for that I'll take a look

    Ian

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I've also set up something similar.

    I have a search form that returns records that match the criteria. Then I use the double click event that uses Docmd.OpenForm with the Where clause that has the PK field for the selected record. The form (I named it EmpDetails) is bound to a query. The open form Where criteria returns one record.

  5. #5
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    HI

    thanks for that. I'm on the learning curve so it means nothing but hopefully after some research , trials I'll understand

    cheers

    Ian

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    *copy your original query with all records
    * add a criteria for what you want to filter.

    So you seem to be filtering by name....

    Add this code to the criteria field for name (if that's what its called) in the design view for your query.
    Like "*" & [Forms]![YourFormName]![YourTXTBoxName] & "*" Or Is Null


    the * will perform a wildcard search based on what you enter... so SM will return SMITH and SMITHY for example.

    Have your form based on this query. Then in the after update event of that text box add the code
    Code:
    Me.requery
    obviously in between the code that's already there.

    Hope this helps.. If not just ask.

    Andy

    just posting because there's many things I found confusing and had to ask multiple times.

  7. #7
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    thanks for the post really helped.

    I finaly ended up using this code to display my list of deceased people and it works well.

    Code:
    Like "*" & [Enter a name]
    I do have a couple of questions

    when you open up the form a box appears which says at the top "Enter Peramter Value" is it possible to edit/delete this text?

    Secondly the code

    Code:
    Me.requery
    where exactly does this go? I right clicked on the text box in the form and then went to the properties and under the tab event added it to the line after update. but is does not seem to do anything, your post also implies that there should be other code there, so clearly I'm missing something

    thanks

    Ian

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Which text box are you putting that code in?

    also:
    Code:
    Like "*" & [Enter a name]
    I would say that needs to reference a specific text box on the form.

    When the form opens it uses that query to generate the results. At that time the box is blank so it uses * and generates all.

    Now in the text box you want to use (and need to reference in the query) that's where you need the code:

    Code:
    Private Sub Search_TXT_AfterUpdate()
    Me.Requery
    End Sub

    where mine says Search_TXT that's where you have your text box name. (it should be there automatically.)

  9. #9
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    Issues with code placement

    Hi

    I feel I may have gone a bit wrong

    My form is based on a query.

    When creating that query I have a field called Surname in that field I added the criteria

    Code:
    Like "*" & [Enter a Surname]
    so that when someone puts in either S or Smith the appropriate records come up and it seems to work.

    This seems to work ok

    If I open the form in design mode and click in the middle of the Surname Field is says Surname if I delete that and paste the code below



    Code:
    Private Sub Surname_AfterUpdate()
    Me.Requery
    End Sub
    when I run the query I see

    [CODE#Name?][/CODE]#Name?

    which I think means invalid path or name?

    Am I missing the point?

    thanks again

    Ian

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    ok a few things, field is at a table level not form. you need to make sure you call your text boxes a text box on the forum to avoid confusion.

    Is the text box called surname? on the form?

    Code:
    [Like "*" & [Forms]![YourFormName]![YourTXTBoxName] & "*" Or Is Null
    < try this

    YourFormName = the form where the text box is you want to reference
    YourTXTBoxName = the text box name

    leave the []! symbols and just make the referencing right.

    tell me the name of your form and the text box and ill add it for you if you don't understand.

    Or upload a sample database.

  11. #11
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    code placement

    HI

    really appreciate the advice and I take on board the naming of fields in tables and text boxes in forms. Apologies for confusion.

    I've added the code you kindly supplied to the criteria field of the Surname field in the query and it seems to be working perfectly.

    However I am still at a loss as to how to use

    Code:
    Private Sub Search_TXT_AfterUpdate()
    Me.Requery
    End Sub
    Do I go into design mode for my form and then just type the code into the Surname text box?

    The table is called "tblGraves Query with search" the form is also called "tblGraves Query with search" and on the form the text box is called Surname

    thanks again

    Ian

  12. #12
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    They are bad names for both form and query, but that wont stop them working haha.

    Your code that you put in the criteria references a specific text box on a specific form now (assuming you did that right). What that means is... your query looks at that box to see what it should look for.

    your query doesn't automatically keep checking that box. You need to tell it when to do so.

    So.... when that box is updated is a good time to requery

    that same box in design view... click the after update event, then tell it to requery.

    Hope this helps.

  13. #13
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi thanks for the info.

    At the risk of seeming even more stupid why are the names bad?

    thanks

    Ian

  14. #14
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Some code doesn't like the spaces so use _ instead of space. I'm no expert on these and I'm fairly new to access myself. Anyway, here's my opinion haha.

    TblGraves is your table for all the graves. There's no need to name that table anything else.

    QryGravesSearch is descriptive, and it states its a query.

    then your form: name FrmGraveSearch.

    just keep them accurate, short and descriptive. But often renaming can break a lot of things, like when you reference a form and change the name. You need to change that name everywhere.

  15. #15
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Have you seen this?
    The Ten Commandments of Access
    http://access.mvps.org/access/tencommandments.htm

    Note #3.

    Should use only letters, numbers and/or the underscore. NO spaces, punctuation or special characters in object names. (Tables/fields, Forms, Queries, Reports, Modules, variables, ....., etc)

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

Similar Threads

  1. Nested IF
    By balajigade in forum Queries
    Replies: 3
    Last Post: 10-04-2014, 10:23 AM
  2. nested iif
    By slimjen in forum Reports
    Replies: 1
    Last Post: 03-15-2014, 09:30 AM
  3. Nested DLookup
    By jamarogers in forum Programming
    Replies: 8
    Last Post: 10-13-2013, 12:20 AM
  4. Replies: 1
    Last Post: 10-29-2012, 11:24 PM
  5. Nested IIF
    By Oldie in forum Queries
    Replies: 1
    Last Post: 02-17-2012, 06:04 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