recordset.AddNew to RS based on query

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

    recordset.AddNew to RS based on query

    Hi.
    Is it possible to add new record to my recordset which is based on a
    query?
    I want to use this recordset only for temp starage of data, and I
    don't want to update values from this recordset to a table.

    Code:
    Q2 = "SELECT T_SMP_RCNR.KEY_ ORDER, T_SMP_RCNR.RCNR ,
    T_SMP_RCNR.KEY_ RCNR " & _
    "FROM T_SMP_RCNR LEFT JOIN Q_MaxOfSMPRCNR ON
    T_SMP_RCNR.KEY_ ORDER = Q_MaxOfSMPRCNR. KEY_ORDER " & _
    "WHERE T_SMP_RCNR.RCNR = [MaxOfSMPRCNR];"

    rstQ2.Open Q2, CurrentProject. Connection, adOpenKeyset,
    adLockOptimisti c

    [...]
    rstQ2.Find "KEY_ORDER LIKE '" & keyOrd & "'"
    If rstQ2.EOF Then
    new_RCNR = 1
    rstQ2.AddNew
    rstQ2!key_order = keyOrd
    rstQ2!RCNR = 1
    rstQ2!key_rcnr = keyOrd & "." & new_RCNR
    rstQ2.Update
    MsgBox rstQ2!key_rcnr
    Else
    new_RCNR = rstQ2!RCNR + 1
    rstQ2!RCNR = new_RCNR
    rstQ2!key_rcnr = keyRcnr
    End If

    If it's not possible (or senseless) - then what different option can I
    choose?

    thanks for help,
    best regards,
    Kamil
  • Steve

    #2
    Re: recordset.AddNe w to RS based on query

    Queries are connected to records in one or more tables and iuf the query is
    updateable those records can be editted and deleted and new records can be
    added. A recordset is just a reflection of records in a table and
    recordset.addne w can add records to the table. So in essence you are dealing
    with live records.

    Describe what you are trying to do and maybe you will get some suggestions
    on hopw to accomplish it.

    Steve



    "Kamil" <kamil.jedrzeje wski@gmail.comw rote in message
    news:c774ea30-dcf2-420d-b8c5-b770d0d8d75f@34 g2000hsf.google groups.com...
    Hi.
    Is it possible to add new record to my recordset which is based on a
    query?
    I want to use this recordset only for temp starage of data, and I
    don't want to update values from this recordset to a table.
    >
    Code:
    Q2 = "SELECT T_SMP_RCNR.KEY_ ORDER, T_SMP_RCNR.RCNR ,
    T_SMP_RCNR.KEY_ RCNR " & _
    "FROM T_SMP_RCNR LEFT JOIN Q_MaxOfSMPRCNR ON
    T_SMP_RCNR.KEY_ ORDER = Q_MaxOfSMPRCNR. KEY_ORDER " & _
    "WHERE T_SMP_RCNR.RCNR = [MaxOfSMPRCNR];"
    >
    rstQ2.Open Q2, CurrentProject. Connection, adOpenKeyset,
    adLockOptimisti c
    >
    [...]
    rstQ2.Find "KEY_ORDER LIKE '" & keyOrd & "'"
    If rstQ2.EOF Then
    new_RCNR = 1
    rstQ2.AddNew
    rstQ2!key_order = keyOrd
    rstQ2!RCNR = 1
    rstQ2!key_rcnr = keyOrd & "." & new_RCNR
    rstQ2.Update
    MsgBox rstQ2!key_rcnr
    Else
    new_RCNR = rstQ2!RCNR + 1
    rstQ2!RCNR = new_RCNR
    rstQ2!key_rcnr = keyRcnr
    End If
    >
    If it's not possible (or senseless) - then what different option can I
    choose?
    >
    thanks for help,
    best regards,
    Kamil

    Comment

    • rkc

      #3
      Re: recordset.AddNe w to RS based on query

      I want to use this recordset only for temp starage of data, and I
      don't want to update values from this recordset to a table.
      [snip]
      If it's not possible (or senseless) - then what different option can I
      choose?
      Senseless is in the eye of the beholder.
      Read up on ADODB and disconnected recordsets.

      Comment

      Working...