Recordset Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    #1

    Recordset Help

    I am looking for help using recordset. I currenty have a form which
    uses recordset.add to add records to a table. the form is designed to
    add multiple records at once by auto incrementing. It stores
    information about T1's so when one T1 is added it adds 24 records one
    for each channel.
    I now would like to be able to use recordset to find a specific T1 and
    either modify the records or delete them. The code I use to add is
    below as well as a sample record. In the sample record I may want to
    change the value "Customer 1" to "Customer 2" or I may simply want to
    delete the record.


    Function AddT1Ports(lngS tart As Long, lngEnd As Long, lngRR As String,
    lngEquip As String, lngLoc As String, lngTrans As String, lngShelf As
    String, lngSlotCard As Long, lngAssignment As String)
    Dim rsPorts As DAO.Recordset
    Dim lngCounter As Long

    Set rsPorts = DBEngine(0)(0). OpenRecordset(" tblT1", dbopentable)

    For lngCounter = lngStart To lngEnd
    With rsPorts
    .AddNew
    .Fields("Equipm ent") = lngEquip
    .Fields("Locati on") = lngLoc
    .Fields("RR") = lngRR
    .Fields("Shelf" ) = lngShelf
    .Fields("Slot") = lngSlotCard
    .Fields("Channe l") = lngCounter
    .Fields("Assign ment") = lngAssignment
    .Fields("Transm ission") = lngTrans
    .Update
    End With
    Next lngCounter

    rsPorts.Close
    Set rsPorts = Nothing

    End Function

    ID/Equipment/Location/RR/Shelf/Slot/Channel/Transmission/Assignment
    3/DSX/OAK/101.12/16/22/1/DS0/Customer 1
    4/DSX/OAK/101.12/16/22/2/DS0/Customer 1
    5/DSX/OAK/101.12/16/22/3/DS0/Customer 1
    6/DSX/OAK/101.12/16/22/4/DS0/Customer 1
    7/DSX/OAK/101.12/16/22/5/DS0/Customer 1
    8/DSX/OAK/101.12/16/22/6/DS0/Customer 1
    9/DSX/OAK/101.12/16/22/7/DS0/Customer 1
    10/DSX/OAK/101.12/16/22/8/DS0/Customer 1
    11/DSX/OAK/101.12/16/22/9/DS0/Customer 1
    12/DSX/OAK/101.12/16/22/10/DS0/Customer 1
    13/DSX/OAK/101.12/16/22/11/DS0/Customer 1
    14/DSX/OAK/101.12/16/22/12/DS0/Customer 1
    15/DSX/OAK/101.12/16/22/13/DS0/Customer 1
    16/DSX/OAK/101.12/16/22/14/DS0/Customer 1
    17/DSX/OAK/101.12/16/22/15/DS0/Customer 1
    18/DSX/OAK/101.12/16/22/16/DS0/Customer 1
    19/DSX/OAK/101.12/16/22/17/DS0/Customer 1
    20/DSX/OAK/101.12/16/22/18/DS0/Customer 1
    21/DSX/OAK/101.12/16/22/19/DS0/Customer 1
    22/DSX/OAK/101.12/16/22/20/DS0/Customer 1
    23/DSX/OAK/101.12/16/22/21/DS0/Customer 1
    24/DSX/OAK/101.12/16/22/12/DS0/Customer 1
    25/DSX/OAK/101.12/16/22/23/DS0/Customer 1
    26/DSX/OAK/101.12/16/22/24/DS0/Customer 1

  • salad

    #2
    Re: Recordset Help

    Brian wrote:
    [color=blue]
    > I am looking for help using recordset. I currenty have a form which
    > uses recordset.add to add records to a table. the form is designed to
    > add multiple records at once by auto incrementing. It stores
    > information about T1's so when one T1 is added it adds 24 records one
    > for each channel.
    > I now would like to be able to use recordset to find a specific T1 and
    > either modify the records or delete them. The code I use to add is
    > below as well as a sample record. In the sample record I may want to
    > change the value "Customer 1" to "Customer 2" or I may simply want to
    > delete the record.
    >
    >
    > Function AddT1Ports(lngS tart As Long, lngEnd As Long, lngRR As String,
    > lngEquip As String, lngLoc As String, lngTrans As String, lngShelf As
    > String, lngSlotCard As Long, lngAssignment As String)
    > Dim rsPorts As DAO.Recordset
    > Dim lngCounter As Long
    >
    > Set rsPorts = DBEngine(0)(0). OpenRecordset(" tblT1", dbopentable)
    >
    > For lngCounter = lngStart To lngEnd
    > With rsPorts
    > .AddNew
    > .Fields("Equipm ent") = lngEquip
    > .Fields("Locati on") = lngLoc
    > .Fields("RR") = lngRR
    > .Fields("Shelf" ) = lngShelf
    > .Fields("Slot") = lngSlotCard
    > .Fields("Channe l") = lngCounter
    > .Fields("Assign ment") = lngAssignment
    > .Fields("Transm ission") = lngTrans
    > .Update
    > End With
    > Next lngCounter
    >
    > rsPorts.Close
    > Set rsPorts = Nothing
    >
    > End Function
    >
    > ID/Equipment/Location/RR/Shelf/Slot/Channel/Transmission/Assignment
    > 3/DSX/OAK/101.12/16/22/1/DS0/Customer 1
    > 4/DSX/OAK/101.12/16/22/2/DS0/Customer 1
    > 5/DSX/OAK/101.12/16/22/3/DS0/Customer 1
    > 6/DSX/OAK/101.12/16/22/4/DS0/Customer 1
    > 7/DSX/OAK/101.12/16/22/5/DS0/Customer 1
    > 8/DSX/OAK/101.12/16/22/6/DS0/Customer 1
    > 9/DSX/OAK/101.12/16/22/7/DS0/Customer 1
    > 10/DSX/OAK/101.12/16/22/8/DS0/Customer 1
    > 11/DSX/OAK/101.12/16/22/9/DS0/Customer 1
    > 12/DSX/OAK/101.12/16/22/10/DS0/Customer 1
    > 13/DSX/OAK/101.12/16/22/11/DS0/Customer 1
    > 14/DSX/OAK/101.12/16/22/12/DS0/Customer 1
    > 15/DSX/OAK/101.12/16/22/13/DS0/Customer 1
    > 16/DSX/OAK/101.12/16/22/14/DS0/Customer 1
    > 17/DSX/OAK/101.12/16/22/15/DS0/Customer 1
    > 18/DSX/OAK/101.12/16/22/16/DS0/Customer 1
    > 19/DSX/OAK/101.12/16/22/17/DS0/Customer 1
    > 20/DSX/OAK/101.12/16/22/18/DS0/Customer 1
    > 21/DSX/OAK/101.12/16/22/19/DS0/Customer 1
    > 22/DSX/OAK/101.12/16/22/20/DS0/Customer 1
    > 23/DSX/OAK/101.12/16/22/21/DS0/Customer 1
    > 24/DSX/OAK/101.12/16/22/12/DS0/Customer 1
    > 25/DSX/OAK/101.12/16/22/23/DS0/Customer 1
    > 26/DSX/OAK/101.12/16/22/24/DS0/Customer 1
    >[/color]
    Are you using a subform to display the T1 and subordinate channel
    records? That's one method I'd use. If you want to do it via code,
    check out Delete and Update queries and Docmd.Execute.


    Comment

    Working...