Results 1 to 8 of 8
  1. #1
    Join Date
    May 2013
    Location
    Baltimore Maryland
    Posts
    15

    Unhappy Query not returning certain data...

    Scenario: I have 2 tables, one called Location and the other called PC Inventory. They both have columns called sites. The query is set to search both tables by site name and return the PC's at that site that match the search criteria.

    The search form has a drop down menu with all the site names. When you choose a site name from the last, the after update event does a re-query to a subform on that same form. The source object of the subform is set the query.

    [Forms]![PC Search]![Combo6] - this is the criteria on the query that point to the drop down menu.
    --------
    Private Sub Combo6_After Update()
    Me.Child19.Requery
    End Sub

    This is the requery that point to the subform (child19)
    --------

    The problem is that some selections from the list don't return any results to the subform. But there is clearly records that meet the criteria in the table. Example: ABC @ Maryland returns all the PC's at the site. DEF @ Maryland doesn't return any PC's at the site, but there are records with that site name.



    Even if go into the table copy the site name that isn't working and enter into the search field it doesn't return the results. Been banging my head for 2 weeks on this, any help is greatly appreciated. Please, if you need any more information or have any questions, I will be happy to provide them!!! Click image for larger version. 

Name:	pic.jpg 
Views:	6 
Size:	19.6 KB 
ID:	18421Click image for larger version. 

Name:	PIC2.png 
Views:	6 
Size:	14.7 KB 
ID:	18422

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    1. FYI, when you put a combo or text box on the form, you can NAME it something else that makes sense, instead of the default COMBO5. In properties, other tab, name. Like: cboSite
    this is readily understandable in a query when you look at the criteria.

    2. Is the sub form props: LINK CHILD FIELD, LINK MASTER FIELD , set properly? To Combo6 on both?

    3. And actually, I think you must refresh the subform, not the child..so: Me.Child19.form.Requery

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can't (well you shouldn't ) link the two tables on "Sites". If "DEF @ Maryland" is in one table but not in the other table, "DEF @ Maryland" will not be in the recordset (the query).

    You can select all records from one table (Location) and only the matching records from the other table (PC Inventory), but if you want to see a record from either table, you have two options:

    1) Fix the table structure
    2) Use a union query. You must type the union query - query wizard can't create it.

    The union query would look like:
    Code:
    SELECT sites From Location
    Union
    SELECT sites From [PC Inventory]
    You should read up on the syntax for union queries. This is off the top of my head - I don't remember exactly what the syntax is.

  4. #4
    Join Date
    May 2013
    Location
    Baltimore Maryland
    Posts
    15
    The form is unbound so i get the error "Cant build a link between unbound forms"

    It work for some of the sites in the list though thats what i don't understand.

    I made the change to the refresh and no difference.

  5. #5
    Join Date
    May 2013
    Location
    Baltimore Maryland
    Posts
    15
    I really only need to see the records from one table and that is PC inventory. My goal is to for the user to select the site from the drop down list and it populate the PC inventory from that site in the subform.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Then the query should use the combo box to filter the records.

    It would be easier to have the combo box in the form header and the records in the detail section.


    Care to post your dB for analysis?

  7. #7
    Join Date
    May 2013
    Location
    Baltimore Maryland
    Posts
    15
    Well that solved my delima... eliminating the second table and just running the query on one table

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Excellent...

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

Similar Threads

  1. Replies: 6
    Last Post: 05-04-2014, 12:53 PM
  2. Replies: 3
    Last Post: 01-24-2013, 02:08 PM
  3. Union Query Returning Different Data
    By deluga.69 in forum Queries
    Replies: 2
    Last Post: 08-15-2011, 01:47 PM
  4. Queries not returning data
    By Verso in forum Queries
    Replies: 1
    Last Post: 08-11-2011, 01:46 AM
  5. Simple Query not returning any data.
    By psoli in forum Queries
    Replies: 4
    Last Post: 06-16-2011, 11:07 AM

Tags for this Thread

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