Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Search through a table

    I am trying to search through a table to find the item in a column that is the same, then using data from a different column/Same row to add to the output. What I need to do is to have the Test Example look up the Code Example [NewWave] and compare it to the NewNetID Table (rN("NetName") all rows in that column. Find the one that is the same and assign it to the string NN. As I have it now, I get an error code 3021: No current record at the EOF. How do I fix this, and how would I get it to search the rN database for each if/Elseif statement?

    Code:
    Private Sub UpdateWave_Click()
    Dim rU As DAO.Recordset, rN As DAO.Recordset, V As String, NN As String, Base as String
    
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
    V= " VHF"
    ' Base  derived from case select series
    
        Do While Not rU.EOF
                    rU.MoveFirst
    
        Do While Not rN.EOF
                    rN.MoveFirst
                    
                    rU.Edit
                    rN.Edit
    
    'Code determining what the data is to compare to.  
    ' Test Example:
    
    For I = 1 To 6
    
        If rN("NBOI_Net") = rU("SINC  " & I) Then          'Test
                NN = rN("NetID")                                   'Test
        End If                                                         'Test
    ' Code Example:
    
        If rU("SINCGARS  " & I) = "ME" Then
                rU("SINC" & I) = "511-ME" & V
        ElseIf rU("SINCGARS  " & I) Like "BBB*" Then
                NewWave = Base & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
        End If
    
               rU![Unit] = Units
                rU.Update
                rU.MoveNext
        Loop
        Loop
    
            rU.Close
            Set rU = Nothing
            rN.Close
            Set rN = Nothing
    
    End Sub
    Thanks
    T

    Yes I know ranman states all this can be done in queries. But I need to other stuff and I do no know how to make a for next for I in 1 query, so that means 6 seperate queries. 1 for each column.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    *sigh*. I think your table is designed wrong if you are searching across fields.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Have you got a sample database so I don't have to re-create the table structure with data to parse your code?

  4. #4
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    rpeare,
    I cleaned it up enough to get across where I am at and what I would like.

    Ranman,
    The table I am searching is not my own, nor is it set in any logical standard.

    Test.accdb

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    your looping structure is off, you are using MOVEFIRST inside the loop where you are cycling through the recordset which is causing problems and you are using .movenext for the external loop inside the inner loop

    on a basic level this is what you have:

    Code:
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
    Do While Not rU.EOF
        rU.MoveFirst  'you will never get to the end of the recordset because you are always moving to the first record every time you loop
        Do While Not rN.EOF
            rN.MoveFirst 'same problem here you will constantly be cycling to the first record
    
            rU.MoveNext
        Loop
        'you aren't cycling to the next record of recordset ru here
    Loop
    this is what it should be:
    Code:
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
    'by default recordsets start at the first record so there is no ru.movefirst required
    Do While Not rU.EOF
        rN.MoveFirst 'for each record in ru, cycle through all records in rn
        Do While Not rN.EOF
            
            rn.movenext  'after you've done what you're going to do with each record of rn, move to the next rn record
        Loop
        ru.movenext 'after you've cycled through all the records in rn, move to the next ru record
    Loop
    Further I would suggest in your code that you have way too much that is hard coded. Every time you change the structure of the database you may have to revisit this code and 'fix' it to handle new cases.


    If you can explain in concrete terms what you want the result to be from the data in this test database we may be able to suggest a better way to get the result you want.

  6. #6
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    rpeare,
    In essence it would be a concatenation of the NewNetID tables controls

    [NetID] & "-" & [NetName] & " " & [Wave] but using the NBOI table as the data origin. There is a lot more data for different waveforms, but I have those figured out already and do not need to reference the NewNetID table.

    1-BCT FS VHF
    2-BCTD O&I VHF
    3-BCT O&I VHF
    4-BCT FIRES VHF
    5-BCT A&L VHF
    6-BCTD CMD VHF
    7-BCT CMD VHF
    8-ABNIN CMD VHF
    9-ABNIN O&I VHF
    10-ABNIN A&L VHF
    11-HHC ABNIN CMD VHF
    12-ABNIN FS VHF
    13-MRT BCT FD VHF
    14-ABNIN F VD VHF
    50-METT-T VHF

    This is overly simplified though.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    did the correction in the looping structure I give you work?

  8. #8
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I get a not responding error. I think this way might be too much for the database?

    Code:
    Private Sub UpdateWave_Click()
    
    Dim rU As DAO.Recordset, rN As DAO.Recordset
    Dim Uname As Variant, PLName As Variant, CoName As Variant
    Dim I As Integer, Z As Integer
    Dim A As String, B As String, V As String, NN As String
    Dim NewWave As String, PLT As String, Company As String, BN As String, DIV As String, Base As String
    Dim BDEs As String, INFBN As String, BEB As String, BSB As String
    
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
     
        V = " VHF"
        BDEs = "BCT"
        INFBN = "ABNIN"
        BEB = "ABEB"
        BSB = "BBSB"
        DIV = "BCTDD"
            
        Do While Not rU.EOF
                    rU.MoveFirst
            Do While Not rN.EOF
                    
                    rU.Edit
                
              Uname = rU![BN (Operating)]
                
                Select Case Uname
                    Case Is = "BDE"
                        Base = BDEs
                        Z = 1
                     Case Is = "INF BN 1"
                        Base = INFBN
                        Z = 3
                    Case Is = "BEB"
                        Base = BEB
                        Z = 7
                    Case Is = "BSB"
                        Base = BSB
                        Z = 9
                    Case Is = "DIV"
                        Base = DIV
                        Z = 0
                    Case Else
                        Base = ""
                End Select
    
            CoName = rU![CO (Operating)]
    
                Select Case CoName
                  Case Is = "HHC"
                        B = "HHC "
                    Case Is = "A"
                        B = "A "
                    Case Is = "B"
                        B = "B "
                    Case Is = "C"
                        B = "C "
                    Case Is = "D"
                        B = "D "
                    Case Else
                        B = ""
                   End Select
    
            PLName = rU![PLT]
    
                Select Case PLName
                     Case Is = "1"
                        A = "1 "
                    Case Is = "2"
                        A = "2 "
                     Case Is = "3"
                        A = "3 "
                    Case Is = "MRT"
                        A = "MORT "
                    Case Is = "MED"
                        A = "MED "
                    Case Is = Null
                        A = ""
                    Case Else
                        A = " "
                   End Select
    
            Company = B & Base
            PLT = A & B & Base
    
    For I = 1 To 2
    
        If rN("NetName") = NewWave And rN("Wave") = "VHF" Then
            NN = rN("NetID")
        End If
    
            If rU("SINCGARS  " & I) = "METT" Then
                rU("SINC" & I) = "50-METT-T" & V
            ElseIf rU("SINCGARS  " & I) Like "Div*" Then
                NewWave = DIV & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "Bde*" Then
                NewWave = BDEs & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "Bn*" Then
                NewWave = Base & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "CO*" Then
                NewWave = Company & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) = "MEDEVAC" Then
                NewWave = "MEDEVAC"
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) = "Sptd Unit A&L" Then
                NewWave = Base & " A&L"
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*OPS" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 4))
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*FD" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 5))
                rU("SINC" & I) = NN & "-" & NewWave & V
    
    
        End If
    Next I
    
                
        Loop
                rU.Update            
                rU.MoveNext
        Loop
                rN.MoveNext
    
                rU.Close
                Set rU = Nothing
                rN.Close
                Set rN = Nothing
    
    End Sub

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    how big is your table, I haven't spent too much time trying to actually parse what you're doing here, I just looked at the elementary structure of the loops.

    It looks like the only thing it's doing is populating SINC1 and SINC2 on the table NBOI and appears to be working on the test database when I use the following code

    Code:
    Option Compare DatabaseOption Explicit
    Private Sub Clear_Click()
    
    
    Dim rU As DAO.Recordset
    
    
    Set rU = CurrentDb.OpenRecordset("NBOI")
                    rU.MoveFirst
    
    
        Do While Not rU.EOF
            rU.Edit
            rU![SINC1] = Null
            rU![SINC2] = Null
            rU.Update
            rU.MoveNext
        Loop
    
    
           rU.Close
           Set rU = Nothing
    End Sub
    Private Sub UpdateWave_Click()
    
    
    Dim rU As DAO.Recordset, rN As DAO.Recordset
    Dim Uname As Variant, PLName As Variant, CoName As Variant
    Dim I As Integer, Z As Integer
    Dim A As String, B As String, V As String, NN As String
    Dim NewWave As String, PLT As String, Company As String, BN As String, DIV As String, Base As String
    Dim BDEs As String, INFBN As String, BEB As String, BSB As String
    
    
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
    
     
    V = " VHF"
    BDEs = "BCT"
    INFBN = "ABNIN"
    BEB = "ABEB"
    BSB = "BBSB"
    DIV = "BCTDD"
            
    Do While Not rU.EOF
    '    rU.MoveFirst
        rN.MoveFirst
        Do While Not rN.EOF
    'GoTo BOOKMARK
            rU.Edit
            rN.Edit
            Uname = rU![BN (Operating)]
                
            Select Case Uname
                Case Is = "BDE"
                    Base = BDEs
                    Z = 1
                Case Is = "INF BN 1"
                    Base = INFBN
                    Z = 3
                Case Is = "BEB"
                    Base = BEB
                    Z = 7
                Case Is = "BSB"
                    Base = BSB
                    Z = 9
                Case Is = "DIV"
                    Base = DIV
                    Z = 0
                Case Else
                    Base = ""
                End Select
    
    
                CoName = rU![CO (Operating)]
                Select Case CoName
                    Case Is = "HHC"
                        B = "HHC "
                    Case Is = "A"
                        B = "A "
                    Case Is = "B"
                        B = "B "
                    Case Is = "C"
                        B = "C "
                    Case Is = "D"
                        B = "D "
                    Case Else
                        B = ""
                End Select
    
    
                PLName = rU![PLT]
                
                Select Case PLName
                    Case Is = "1"
                        A = "1 "
                    Case Is = "2"
                        A = "2 "
                    Case Is = "3"
                        A = "3 "
                    Case Is = "MRT"
                        A = "MORT "
                    Case Is = "MED"
                        A = "MED "
                    Case Is = Null
                        A = ""
                    Case Else
                        A = " "
                    End Select
    
    
                Company = B & Base
                PLT = A & B & Base
    
    
                For I = 1 To 2
                    If rN("NetName") = NewWave And rN("Wave") = "VHF" Then
                        NN = rN("NetID")
                    End If
    
    
                    If rU("SINCGARS  " & I) = "METT" Then
                        rU("SINC" & I) = "50-METT-T" & V
                    ElseIf rU("SINCGARS  " & I) Like "Div*" Then
                        NewWave = DIV & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) Like "Bde*" Then
                        NewWave = BDEs & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) Like "Bn*" Then
                        NewWave = Base & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) Like "CO*" Then
                        NewWave = Company & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) = "MEDEVAC" Then
                        NewWave = "MEDEVAC"
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) = "Sptd Unit A&L" Then
                        NewWave = Base & " A&L"
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) Like "*OPS" Then
                        NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 4))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    ElseIf rU("SINCGARS  " & I) Like "*FD" Then
                        NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 5))
                        rU("SINC" & I) = NN & "-" & NewWave & V
                    End If
                    Debug.Print "SINC" & I
                Next I
            rU.Update
            rN.MoveNext
        Loop
        rU.MoveNext
    Loop
    
    
                rU.Close
                Set rU = Nothing
                rN.Close
                Set rN = Nothing
                
    Debug.Print "DONE"
    End Sub
    If you are running another update on this data you may want to limit your selection criteria for each dataset to items without a SINC1 or SINC2 value so this process doesn't re-write existing records.

  10. #10
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Below is the full code for the networks: I have only 3500 Rows of data in the table. I don't think I have anything else updating.

    Code:
    Dim rU As DAO.Recordset, rN As DAO.Recordset
    Dim Uname As Variant, PLName As Variant, CoName As Variant
    Dim Max As Integer, I As Integer, M As Integer, Z As Integer
    Dim A As String, B As String, H As String, S As String, W As String, V As String, NN As String
    Dim NewWave As String, Units As String, PLT As String, Company As String, BN As String, DIV As String, Base As String
    Dim BDEs As String, INFBN As String, ARBN(2), CAV As String, Fires As String, BEB As String, BSB As String, Air As String
    
    Set rU = CurrentDb.OpenRecordset("NBOI")
    Set rN = CurrentDb.OpenRecordset("NewNetID")
    
        H = " HF"
        S = " SRW(C)"
        W = " WNW(C)"
        V = " VHF"
        W = " WNW(C)"
        BDEs = "2BCT1ID"
        Air = "AVN TF"
        INFBN = "1BN18IN"
        ARBN(1) = "1BN63AR"
        ARBN(2) = "2BN70AR"
        CAV = "5BN4CAV"
        Fires = "1BN7FA"
        BEB = "82BEB"
        BSB = "299BSB"
        DIV = "1ID"
        Max = 13500
                         
    Do While Not rU.EOF
        rN.MoveFirst
        Do While Not rN.EOF
            rU.Edit
            rN.Edit
                                   
              Uname = rU![BN]
                
                Select Case Uname
                    Case Is = "BDE"
                        Base = BDEs
                        Z = 1
                    Case Is = "AERIAL"
                        Base = Air
                        Z = 1
                    Case Is = "INF BN 1"
                        Base = INFBN
                        Z = 3
                    Case Is = "AR BN 1"
                        Base = ARBN(1)
                        Z = 4
                    Case Is = "AR BN 2"
                       Base = ARBN(2)
                        Z = 5
                    Case Is = "CAV"
                        Base = CAV
                        Z = 6
                    Case Is = "Fires"
                        Base = Fires
                        Z = 8
                    Case Is = "BEB"
                        Base = BEB
                        Z = 7
                    Case Is = "BSB"
                        Base = BSB
                        Z = 9
                    Case Is = "DIV"
                        Base = DIV
                        Z = 0
                    Case Else
                        Base = ""
                End Select
    
            CoName = rU![CO]
    
                Select Case CoName
                   Case Is = "HHB"
                        B = "HHB "
                  Case Is = "HHC"
                        B = "HHC "
                    Case Is = "HHT"
                        B = "HHT "
                    Case Is = "A"
                        B = "A "
                    Case Is = "B"
                        B = "B "
                    Case Is = "C"
                        B = "C "
                    Case Is = "D"
                        B = "D "
                    Case Is = "E"
                        B = "E "
                    Case Is = "F"
                        B = "F "
                    Case Is = "G"
                        B = "G "
                    Case Is = "H"
                        B = "H "
                    Case Is = "I"
                        B = "I "
                    Case Else
                        B = ""
                   End Select
    
            PLName = rU![PLT]
    
                Select Case PLName
                    Case Is = "TRAN"
                        A = "1 "
                     Case Is = "HQ"
                        A = "HQ "
                     Case Is = "1"
                        A = "1 "
                    Case Is = "2"
                        A = "2 "
                    Case Is = "SUP"
                        A = "2 "
                    Case Is = "3"
                        A = "3 "
                    Case Is = "ES"
                        A = "ES "
                    Case Is = "RCL"
                        A = "RTE CLR "
                    Case Is = "4"
                        A = "4 "
                    Case Is = "SGI"
                        A = "SGI "
                    Case Is = "SCT"
                        A = "SCT "
                    Case Is = "SNP"
                        A = "SNP "
                    Case Is = "SUP"
                        A = "SUP "
                    Case Is = "TUAS"
                        A = "TUAS "
                    Case Is = "TGT"
                        A = "TAP "
                    Case Is = "FUEL & WAT"
                        A = "F&W "
                    Case Is = "MRT"
                        A = "MORT "
                    Case Is = "MED"
                        A = "MED "
                    Case Is = Null
                        A = ""
                    Case Else
                        A = " "
                   End Select
                   
            Units = Base
            Company = B & Base
            PLT = A & B & Base
    'MOUS
            If rU![MUOS  1] = "METT" Then
              rU("MUOS1") = "11500-METT-T MUOS"
            Else: rU("MUOS1") = ""
            End If
    'HF
            If rU("HF  1") = "METT" Then
                rU("HF1") = "13000-METT-T" & H
            ElseIf rU("HF  1") Like "BDE*" Then
                NewWave = Right(rU("HF  1"), (Len(rU("HF  1")) - 4))
                rU("HF1") = Max - Z & "-" & BDEs & " " & NewWave & H
            ElseIf rU("HF  1") = "Bn Intel" Then
               NewWave = Right(rU("HF  1"), (Len(rU("HF  1")) - 2))
                rU("HF1") = Max - Z - 10 & "-" & Base & NewWave & H
            ElseIf rU("HF  1") = "Bn Cmd" Then
               NewWave = Right(rU("HF  1"), (Len(rU("HF  1")) - 2))
                rU("HF1") = Max - Z & "-" & Base & NewWave & H
            ElseIf rU("HF  1") Like "Co Cmd" Then
                NewWave = Right(rU("HF  1"), (Len(rU("HF  1")) - 2))
                rU("HF1") = Max - Z - 100 & "-" & B & Base & NewWave & H
            ElseIf rU("HF  1") Like "Div FS" Then
                NewWave = DIV & " " & Right(rU("HF  1"), (Len(rU("HF  1")) - 4))
                rU("HF1") = Max - Z - 300 & "-" & NewWave & H
         End If
    
    For I = 1 To 2  'WNW
        
            If rU("WNW  " & I) = "METT" Then
                rU("WNW" & I) = "10500-METT-T" & W
            ElseIf rU("WNW  " & I) = "BDE" Then
                rU("WNW" & I) = "10001-" & BDEs & W
            ElseIf rU("WNW  " & I) = "BN" Then
                rU("WNW" & I) = "1000" & Z & "-" & Base & W
            ElseIf IsNull(rU("WNW  " & I)) Then
               rU("WNW" & I) = ""
            End If
    
    Next I
    
    For I = 1 To 6
    
                    If rN("NetName") = NewWave And rN("Wave") = "VHF" Then
                        NN = rN("NetID")
                    End If
    
            If rU("SINCGARS  " & I) = "METT" Then
                rU("SINC" & I) = "12500-METT-T" & V
            ElseIf rU("SINCGARS  " & I) Like "Div*" Then
                NewWave = DIV & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "Bde*" Then
                NewWave = BDEs & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "Bn*" Then
                NewWave = Base & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) Like "CO*" Then
                NewWave = Company & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 2))
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) = "MEDEVAC" Then
                NewWave = "MEDEVAC"
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) = "Sptd Unit A&L" Then
                NewWave = Base & " A&L"
                rU("SINC" & I) = NN & "-" & NewWave & V
            ElseIf rU("SINCGARS  " & I) = "Sptd Unit Cmd" Then
                NewWave = Company & " Cmd"
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "?? OPS" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 3))
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*TA*" Then
                NewWave = PLT & " TA"
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*Flight*" Then
                NewWave = PLT & " " & "Flt Ops"
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*OPS" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 4))
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*FD" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 5))
                rU("SINC" & I) = NN & "-" & NewWave & V
           ElseIf rU("SINCGARS  " & I) Like "*TA Intel" Then
                NewWave = PLT & " " & Right(rU("SINCGARS  " & I), (Len(rU("SINCGARS  " & I)) - 5))
                rU("SINC" & I) = NN & "-" & NewWave & V
        End If
                Next I
            rU.Update
            rN.MoveNext
        Loop
            rU.MoveNext
    Loop
            rU.Close
            Set rU = Nothing
            rN.Close
            Set rN = Nothing
    End Sub

  11. #11
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Well you've changed your data structure so I can't run this code. Do you want to upload another sample database?

  12. #12
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    rpeare,
    I did not do one of the SRW waveform.
    See below
    Test.zip

    If it can be done easier via a query?

  13. #13
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    3852 x 343 = 1321236 permutations

    There must be some way to make this more efficient

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you explain in simple terms exactly what you're trying to do here. The way you're going about this doesn't make any sense to me, you should only be cycling through the NBOI recordset one time and only looking up values from the NewNetID recordset as needed. I really don't understand why you seem to be updating two fields with exactly the same information as well.

    Finally an example of the expected output for every combination of input would be good too I just have no idea why you are cycling through the inner loop when you really are only updating fields in the outer loop.

  15. #15
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I am wanting to get the NETID added to the output of the rU database.

    NetID & "-" & Unit Name & Wave as requested in the NBOI. The NBOI and the NewNet are not my products. I am using them. The reason there are the same networks in different fields as it is required by the network architecture for those radios. Each column is a radio network. Each row is where that radio is assigned. In each cross between the row and column, if filled in, is the network that radio should be on.

    So I have to figure out the assigned units name for that cell, determine the wave form, and then using those two items, determine the NetID for that radio set. repeat, rinse, repeat. Since there is no logical way the NETID is determined, therefore the need reference the netid. I'd prefer determining my own NetIDs logically using the select case function. most of the code came from that idea, My own NetIDs logically using the select case function.

    If I do not use the NetID field then the VBA runs fast. I am amicable to a more efficient way. Maybe a DLookup instead of a search through the field in NBOI for each iteration.

    3852 * 12 * 343 = 15854832. I didn't look at it that way, but I guess its a lot.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search changes the main table
    By cuddles in forum Forms
    Replies: 2
    Last Post: 05-12-2014, 01:37 PM
  2. Wilcard search using table
    By raytackettsells in forum Queries
    Replies: 6
    Last Post: 10-15-2013, 10:36 AM
  3. Replies: 25
    Last Post: 03-19-2013, 10:08 PM
  4. Replies: 1
    Last Post: 04-11-2012, 03:30 PM
  5. Search in a table and display subform
    By smahdih in forum Access
    Replies: 2
    Last Post: 10-29-2011, 01:46 PM

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