Results 1 to 3 of 3
  1. #1
    JosmithTwo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    19

    read multiple recordsets

    I'm trying to read one recordset and write it to two other recordsets. The problem in the following code is it will fill the variables for ISA, GS and ST and setting breakpoints I see it finds AK2, IK3, IK4 and CTX but the variables never get set (e.g. xAK2Set = !Fileld01 will be empty.



    Why does it work for Case "ISA" - xProd = !field15 but not Case "AK2" xAK2Set = !Fileld01?

    Code:
        Dim db As Database
        Dim rstIN, rstHeader, rstIK5, rstAK9, rstSeg As Recordset
        Dim tableName, theFileAndPath As String
        Dim xProd, xDate, xTime, xSTID, xAK2Set, xAK2Ctl, xIK3Seg As String
        Dim xIK3Pos, xIK3Loop, xIK3Err, xIK4Pos, xIK4Ref, xIK4Err, xIK4Date, xCTXErr As String
    
       Set db = CurrentDb()
       Set rstIN = db.OpenRecordset("tbl_999")
       Set rstHeader = db.OpenRecordset("tbl_999_010_Header")
       Set rstSeg = db.OpenRecordset("tbl_999_020_ErrSegments")
    
       lineCount = 0
       linesWritten = 0
    
        With rstIN
        .MoveFirst
        Do While Not .EOF
            Select Case !field00
                Case "ISA"
                    xProd = !field15
                Case "GS"
                    xDate = !Field04
                    xTime = !field05
                    rstHeader.AddNew
                    rstHeader.FileName = theFileName
                    rstHeader.FileDate = Mid(xDate, 5, 2) & "/" & Right(xDate, 2) & "/" & Left(xDate, 4)
                    rstHeader.FileTime = Left(xTime, 2) & ":" & Right(xTime, 2)
                    rstHeader.ProdTest = xProd
                    rstHeader.Update
                Case "ST"
                    xSTID = !Field02
                Case "AK2"
                    xAK2Set = !Fileld01
                    xAK2Ctl = Left(!Field02, (Len(!Fileld02) - 1))
                Case "IK3"
                    xIK3Seg = !Fileld01
                    xIK3Pos = !Fileld02
                    xIK3Loop = !Fileld03
                    xIK3Err = Left(!Field04, (Len(!Fileld04) - 1))
                Case "IK4"
                    xIK4Pos = !Fileld01
                    xIK4Ref = !Fileld02
                    xIK4Err = !Fileld03
                    xIK4Date = Left(!Field04, (Len(!Fileld04) - 1))
    
                   etc...
    
            End Select
            .MoveNext
        Loop

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Check spelling of fields: Fileld01, Fileld02, Fileld03, Fileld04

    Those are actual field names? Could be more meaningful.
    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
    JosmithTwo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    19
    Thanks so much! I'm getting too old for this stuff.

    The names are meaningful in an EDI environment...

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

Similar Threads

  1. Add records using recordsets
    By mrfixit1170 in forum Programming
    Replies: 12
    Last Post: 05-15-2012, 09:29 AM
  2. Multiple Users Can't Read
    By Hulkdog in forum Access
    Replies: 7
    Last Post: 01-24-2012, 01:46 PM
  3. Newbie. Trying to understand recordsets.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-22-2011, 08:48 AM
  4. Recordsets, add new, DAO and ADO
    By Arca in forum Programming
    Replies: 1
    Last Post: 04-07-2008, 03:57 PM
  5. Replies: 2
    Last Post: 10-19-2006, 04:37 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