Results 1 to 4 of 4
  1. #1
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50

    Data Import Programming and data distribution

    Hello,



    I am pretty far now and taking the last steps. In the attachement I have put a sample DB with my issue. Problem is that after distributing the data the ID in the last table is not correct is not correct.

    Trust the db will give you some explanation.
    Attached Files Attached Files

  2. #2
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50
    After reading my question again, it may need some additional info.

    If you start with clean tables (except tblImEx) then after clicking the button on form1, the tblVoyageData is added the V-record of tblImEx with VoyageDataID=1. The C-records are added to tblContainerData with ContainerDataID=1 and ContainerDataID=2. Both have the same VoyageDataID (=1). Both are related to the same Voyage. This is going OK even if you click the button several times.
    Both records from the tblContainerData must be related to resp 3 and 4 U-records in tblUNComplete. Which records from the U-records related to which ContainerDataID can be found in tblImEx field ImEx1 where you can find a 1 or a 2.

    I was thinking for some kind of loop: You select one C-records (from tblImEx) find the related U records (in tblImEx) and add these to the tblContainerData and tblUNComplete.

    Hope this clarifies it a little bit.
    Last edited by MrDummy; 03-29-2016 at 06:56 AM. Reason: Additional Info

  3. #3
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50
    I am moving ahead. I have inserted a loop and it does go at least once. But it should run for every C record in tblImEx. Somebody has a suggestion:

    Code:
    With Rst
    
    
    Rst.MoveFirst
    Do Until Rst.EOF
    
    If Rst.Fields("ImEx0").Value = "C" Then
    
    lng2ID = Rst.Fields("ImEx3").Value
    lng3ID = Rst.Fields("ImEx4").Value
    
    If Rst1.Fields("ContainerNumber").Value = lng3ID And Rst1.Fields("BookingRef") = lng2ID Then
    
    CdID = Rst1.Fields("ContainerDataID").Value
    
    strSql2 = "INSERT INTO [tblUNComplete] (ContainerDataID, VoyageDataID, UNComplLetter, UNVar, TechnicalName, SuppPSNID, AddSegGrp, LTDQTY ) " & _
    "SELECT " & CdID & " As NewID, ImEx2, ImEx0, ImEx3, ImEx4, ImEx5, ImEx6, ImEx7 " & _
    "FROM [tblImEx] WHERE ImEx1 = " & "'" & lng3ID & "'" & ";" 
    DoCmd.RunSQL strSql2
    End If
    End If
    
    
    Rst.MoveNext
    
    Loop
    
    End With

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Somewhere in your set up you have referenced a table called tblAddInfo, and it isn't in your database.
    I don't use subdatasheets, so am not sure what you have done, are trying to do, or have left some remnants of old code???

    You have defined 3 sql strings to modify your Container, voyage and Uncomplete tables.
    Since you only have 1 import layout, you could set up a loop to

    - Read a record from ImEx
    - select case ImEx0
    Case "V" USE SQLVoyage
    Case "C" Use SQLContainer
    Case "U" Use SQLUnComplete
    -Loop


    Good luck.

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

Similar Threads

  1. Programming to Input Data into a SubForm
    By Edtheredhead in forum Forms
    Replies: 1
    Last Post: 03-31-2016, 11:09 AM
  2. Replies: 2
    Last Post: 06-25-2015, 03:56 PM
  3. Equal Distribution of Data
    By manik.nag in forum Queries
    Replies: 4
    Last Post: 05-20-2015, 09:41 AM
  4. Replies: 3
    Last Post: 01-05-2015, 02:21 PM
  5. Import Raw Data and Export Report data into XLS
    By jjaccess in forum Import/Export Data
    Replies: 1
    Last Post: 06-24-2013, 11:28 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