469,631 Members | 1,298 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

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,
adLockOptimistic

[...]
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
Aug 1 '08 #1
2 1936
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.addnew 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" <ka****************@gmail.comwrote in message
news:c7**********************************@34g2000h sf.googlegroups.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,
adLockOptimistic

[...]
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

Aug 2 '08 #2
rkc
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.
Aug 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Gerry Abbott | last post: by
1 post views Thread by Jason Lepack | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.