Results 1 to 3 of 3
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Checking If Extra Data Added

    Hi Guy's, i am trying to find a method of checking if data exists in tblEdit and it Doesn't Exist in tblRoutes



    So i use the following to add next weeks planning

    Importing the week

    Code:
    dtShipdate = Format(Me.cboWeek, "mm/dd/yyyy")
    
    
    
    strSQL = "INSERT INTO tblRoutes ( DelTo, Town, PostCode ) " _
            & " SELECT tblEdit.DelTo, tblEdit.Town, tblEdit.PostCode " _
            & "From tblEdit " _
            & "GROUP BY tblEdit.ShipmentDate, tblEdit.DelTo, tblEdit.Town, tblEdit.PostCode " _
            & "HAVING (((tblEdit.ShipmentDate)= #" & dtShipdate & "#));"
            
            
        
        DoCmd.SetWarnings False
            DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        
        Forms!frmPlanning!frmPlanningDS.Requery
        
        
        Set rs = CurrentDb.OpenRecordset("Select * From tblRoutes")
        With rs
        
        Do Until rs.EOF
            .Edit
            strPC = rs.Fields("PostCode")
            
            If Not IsNull(iDrop = DLast("DelNo", "tblAssign", "[PostCode] = '" & strPC & "'")) Then
                iDrop = DLast("DelNo", "tblAssign", "[PostCode] = '" & strPC & "'")
                Else
                iDrop = "0"
            End If
            
            iQty = DCount("PostCode", "tblEdit", "[PostCode] = '" & strPC & "' And [ShipmentDate] = #" & dtShipdate & "#")
            
            If Not IsNull(dtLastDate = DLast("DeliveryDate", "tblAssign", "[PostCode] = '" & strPC & "'")) Then 'Checking We have delivered to before
                dtLastDate = DMax("DeliveryDate", "tblAssign", "[PostCode] = '" & strPC & "'")
                Else
                dtLastDate = Format(Now(), "dd/mmm/yyyy")
            End If
            
            .Fields("DelDate") = dtLastDate
            .Fields("DayName") = Format(.Fields("DelDate"), "dddd")
            .Fields("DelNo") = iDrop
            .Fields("Qty") = iQty
            
            .Update
            .MoveNext
        Loop
    
    
    End With
    
    
    Forms!frmPlanning!frmPlanningDS.Requery
    Now Looking for the method for:

    After updating tblRoutes, there maybe addition items added in tblEdit

    I now want to check tblEdit if Postcode Exists (someone else has added items) in tblEdit that doesn't exist in tblRoutes within the shipment week (dtShipDate)

    it doesn't matter if there are additional for the same postcode (Abort or Exit Sub)

    it does matter if the postcode (records added) for a different postcode

    Hope this makes sense

  2. #2
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Just thinking, it may be easy to re-import week but, made changes to fields so would prefer to add extra than a new import

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Got this one

    Code:
    Dim strPC As String, strSQL As StringDim rs As DAO.Recordset
    Dim dtShipDate As Date
    
    
    dtShipDate = Format(Me.cboWeek, "mm/dd/yyyy")
    
    
    strSQL = "SELECT tblEdit.DelTo, tblEdit.Town, tblEdit.PostCode, tblEdit.ShipmentDate " _
            & "FROM tblEdit LEFT JOIN tblRoutes ON tblEdit.[PostCode] = tblRoutes.[PostCode] " _
            & "WHERE (((tblRoutes.PostCode) Is Null) AND ((tblEdit.ShipmentDate)= #" & dtShipDate & "#));"

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

Similar Threads

  1. Replies: 3
    Last Post: 03-11-2020, 11:59 AM
  2. Query relationships creating extra data
    By Numpty in forum Queries
    Replies: 13
    Last Post: 02-22-2019, 05:01 AM
  3. Extra data
    By newtoAccess in forum Reports
    Replies: 14
    Last Post: 11-28-2010, 12:05 AM
  4. Checking for data in table
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 07-27-2010, 01:32 PM
  5. Extra space added
    By allenf in forum Forms
    Replies: 2
    Last Post: 07-25-2010, 06:57 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