Results 1 to 8 of 8
  1. #1
    donnie.atchison is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Jul 2018
    Posts
    12

    How to limit a search on one field based on data in another field.

    I have a data base used for cargo tracking. In cargo tracking we use multiple gps devices on a shipment. Each GPS Device (Tracker) is identified by a 4 digit number. The tracker will be assigned to the shipment in the database. When the shipment is complete the GPS Device (Tracker) is mailed back to me and I enter it as returned in the database. What I am trying to do is build a return form that will only display the record where the device number exists with out device returned check box is false.



    I am able to search for the device but do not know how to have it filter by the Device return check box.

    Here is a screen shot of the return form screen.
    Click image for larger version. 

Name:	Tracker Return Form.PNG 
Views:	17 
Size:	35.3 KB 
ID:	35331

    This is the VBA that I have at this point. Once again it will search for the tracker but I need it only to display the record that contains the GPS device that has not been checked returned in the Tracker Returned check box.

    Private Sub txtSearch_AfterUpdate()
    Dim strFilter As String
    Dim sSearch As String

    If Me.txtSearch <> "" Then
    sSearch = "'*" & Replace(Me.txtSearch, "'", "''") & "*'"
    strFilter = "[Tracker Assigned 1] Like " & sSearch & " OR [Tracker Assigned 2] Like " & sSearch & " OR [Tracker Assigned 3] Like " & sSearch
    Me.Filter = strFilter
    Me.FilterOn = True
    Else
    Me.Filter = ""
    Me.FilterOn = False
    End If

    If Me.Recordset.RecordCount = 0 Then
    If MsgBox("No Record Found") = vbNo Then
    Me.FilterOn = False
    txtSearch = Null
    Exit Sub
    End If
    Me.FilterOn = False
    Exit Sub
    End If
    With Me.txtSearch
    .SetFocus
    .SelStart = Len(Me.txtSearch)
    End With
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Each record has 3 tracker fields? This is not normalized structure. Which do you want to consider for the returned criteria?

    Please post lengthy code within CODE tags to retain indentation and readability.
    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
    donnie.atchison is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Jul 2018
    Posts
    12
    I want to find the Tracker Assigned that that do not have the Tracker returned checked. I need to be able to search all Tracker assigned fields for the tracker number.

  4. #4
    donnie.atchison is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Jul 2018
    Posts
    12
    Private Sub txtSearch_AfterUpdate() Dim strFilter As String
    Dim sSearch As String

    If Me.txtSearch <> "" Then
    sSearch = "'*" & Replace(Me.txtSearch, "'", "''") & "*'"
    strFilter = "[Tracker Assigned 1] Like " & sSearch & " OR [Tracker Assigned 2] Like " & sSearch & " OR [Tracker Assigned 3] Like " & sSearch
    Me.Filter = strFilter
    Me.FilterOn = True
    Else
    Me.Filter = ""
    Me.FilterOn = False
    End If

    If Me.Recordset.RecordCount = 0 Then
    If MsgBox("No Record Found") = vbNo Then
    Me.FilterOn = False
    txtSearch = Null
    Exit Sub
    End If
    Me.FilterOn = False
    Exit Sub
    End If
    With Me.txtSearch
    .SetFocus
    .SelStart = Len(Me.txtSearch)
    End With
    End Sub

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Copying your code in another post was not useful.

    Took another look at form. That is one record with 30 tracker fields? I think you have been advised to normalize this data structure. Should be another table that is dependent to the shipment. Each record will be one tracker assigned to shipment. I still think the Lending Library template could be adapted for your situation.
    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.

  6. #6
    donnie.atchison is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Jul 2018
    Posts
    12
    I have looked at the Lending Library and I do not think it will work for what I need to accomplish. In my situation we are tracking trucks (Shipment Number (Primary Key)) that have up to 30 pallets with each pallet containing a Global Positioning System Tracker (Tracker 1 to 30). Each tracker needs to correspond with the Shipment number. The GPS tracker 1 through 30 could be any of the 300+ GPS trackers we have on hand. Each GPS trackers name is a four digit number and any of the 300 trackers could be placed on Pallet 1(Tracker 1) or pallet 2 (tracker 2) and so on. When a GPS device (Tracker) is returned I need to be able to log it as returned in the data base. I am trying to have the report search by a drop down listing all tracker numbers and search for the tracker number being returned that has been checked out. Do you have any suggestions for me.

    And thanks for your help.

  7. #7
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    June is saying that your table design is not ideal for the data you are trying to capture and report on.

    Without knowing all the details, I would have said you need a ShipmentTable, GPSTracker table , a Truck table , a pallet table , and a junction table(s) recording the ShipmentID, TruckID, PalletID and Tracker ID's with an issued date and a return date.

    This would mean you could easily search for all those records with a null return date.
    If you can post up a picture of your table designs / relationships I'm sure we can point you in the right direction.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Shipment and tracker would be synonymous with person and book. Create record in junction table for each tracker assigned to shipment. Same record is retrieved to enter return date, just like book checked out then back in. This provides history.
    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. Limit record entries based on number in field
    By lamore48 in forum Access
    Replies: 5
    Last Post: 02-12-2018, 02:05 PM
  2. Replies: 13
    Last Post: 11-30-2016, 09:59 AM
  3. Replies: 3
    Last Post: 01-09-2015, 05:48 PM
  4. Replies: 4
    Last Post: 01-23-2014, 04:34 PM
  5. Limit data entry based on another field
    By chemengr in forum Forms
    Replies: 5
    Last Post: 01-02-2014, 01:21 PM

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