Results 1 to 9 of 9
  1. #1
    MarksinMO is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    13

    Searching a Query through a Form doesn't find all records and then deletes record

    I have a database for parts tracking ... it has the following Tables - tblPartsDatabase, tblReceive, tblUsed. I have forms to Create New Part, Receive (of parts), Usage (of parts). I have 2 query's that SUM the Receive and Usage Tables and a third query that results in the On Hand Quantity Using all the data in the tblPartsDatabase. Now the issue ... I have a form that searches the query based on a number of parameters the user Inputs (7 different unbound search boxes). I am in the testing mode ... I added a new part through the New Part form and everything works. Then I receive a quantity of the new part in ... this works. I run all the queries and the results are correct. Then I do a search for the new part ... the datasheet shows the item but when I run the search using the Part Number it doesn't find the part (it does find others since I used LIKE for the filter). Then if I clear the search the record for new part does not show up in the datasheet list. Basically when I open the search form I have 2226 records ... once I run ANY search record 2226 has been deleted. I'm sure this is some relationship issue that I am missing. The newest part "received" is record 2226 w/ PartNum 9007C52D ... Something I just noticed is that this does not show up in the record bar on the bottom left - 1st screen shot. The second screen shot is after I selected record 2225 and then re-selected record 2226 on the datasheet. The third screen shot is doing a search for 9007C and the results as shown. The fourth screen shot is after resetting the search field and clicking on search again - Record 2226 is gone. If I close the Part Search and reopen it ... the results again are screen shot 1.



    I am quite new (a rookie or novice would be superior to me !!) to access and would appreciate any assistance and guidance ... what am I missing !!!


    Click image for larger version. 

Name:	Search.PNG 
Views:	9 
Size:	34.0 KB 
ID:	21989Click image for larger version. 

Name:	Search1.PNG 
Views:	9 
Size:	34.9 KB 
ID:	21990Click image for larger version. 

Name:	Search2.PNG 
Views:	9 
Size:	32.2 KB 
ID:	21991Click image for larger version. 

Name:	Search3.PNG 
Views:	9 
Size:	34.2 KB 
ID:	21992

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need to review data structure, form design, code. 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.

  3. #3
    MarksinMO is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    13

    DB attached

    Let me know if you get this ... Thanks
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Ok, got it.

    Problem starts with table relationships. ID in tblPartsDatabase is autonumber and defined as primary key yet you are saving both ID and ManuPartNum into tblReceive and tblUsed. The defined PK should be the value saved as FK. There is no need to save ManuPartNo into the related tables, save only the ID and link tables on the PK/FK pair.

    Then in QryQtyOH you have tblPartsDatabase join to QryUsed and QryRecv on both ID and ManuPartNum fields (compound link). Should be joining only on one pair (PK to FK). And don't use INNER JOIN, use outer (LEFT or RIGHT) - "Include all records from tblPartsDatabase and only those from QryUsed that match".

    Why are you basing this search form on a query that has aggregate data - just to get the OnHand value? You are aware won't be able to edit the tblPartsDatabase data from this form because of including the aggregate queries?

    Why include tblPartsDatabase in the aggregate queries?

    Suggest you give the ID fields more meaningful names so will be less confusing which field is referenced.
    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
    MarksinMO is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    13
    Thanks for the reply ... I'll muddle through (again a hack) your analysis and figure out how to correct ... The search/query is to get the OnHand Quantity but also to pick up all other data since the mechanics will this available to them in the future ... I have a different form to edit the database and I'm going to modify the tblPartsDatabase to eliminate QtyOH, QtyRecv & QtyUsed ... since that info is coming from the queries. I have do not want any editing of the data in the query just basically "read only". Not sure what you mean by Meaningful names? ... rename ID to ControlNumber?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If every table has a field ID then how to distinguish them if several show in same query?

    So you could do something like: PartsID_PK, PartsID_UsedFK, PartsID_RecdFK

    Or don't do anything and deal with the multiple ID field names. Your choice.
    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.

  7. #7
    Join Date
    Sep 2015
    Location
    Arlington,tx
    Posts
    4
    one thing to keep in mind is that if you have used a wildcard operator "LIKE" and used "*" (thinking that will bring back all records) it wont test true for NULL fields contained in the query

  8. #8
    MarksinMO is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    13
    June7 ... thanks for the direction ... I modified the queries / forms and searches and accomplished everything I needed. Now to CG51's issue ... he's correct in the NULL fields ... is there a work around for this?

    Mark

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Options:

    1. calculate a field in query that handles possible nulls and apply filter criteria to the constructed field
    IIf([fieldname] Is Null, "", [fieldname])

    2. add Or Is Null to the criteria
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-10-2014, 02:05 PM
  2. Replies: 4
    Last Post: 07-03-2013, 10:02 AM
  3. Code deletes too much records
    By JeroenMioch in forum Access
    Replies: 2
    Last Post: 01-03-2013, 08:06 AM
  4. Replies: 8
    Last Post: 07-13-2012, 04:53 PM
  5. Replies: 7
    Last Post: 12-15-2010, 09:46 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