473,395 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2082
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: belacyrf | last post by:
Here's the code: ------------------------------------------------------------------- accessID = request("accessID") strSQL = "SELECT * From PendingAccRequests Where AccessID = "&accessID ...
22
by: Gerry Abbott | last post by:
Hi all, I having some confusing effects with recordsets in a recent project. I created several recordsets, each set with the same number of records, and related with an index value. I create...
1
by: Ryan | last post by:
Hello, I have a quick question (I hope). I have a form with a combo box and a multi-selection list box. The list box is based on a query. Users can select values from the cmbobox to add to...
2
by: Harold | last post by:
Sat I have a customers table with the fields CustomerID and Customer and I use the recordset.addnew method to add a new record to the table. What is the best way to get the CustomerID of the new...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
5
by: tony010409020622 | last post by:
I just spent 4 months taking a dotnet class where i learned very little. One of the things I did not learn is this: What are the dotnet equivilents of commands such as: Adodc1.Recordset.AddNew...
1
by: Jason Lepack | last post by:
I have a loop that loops through all records in all tables that have "TSE" as the first letters. In that loop, based upon conditions of the current record I have to add records to 1 of 5 different...
3
by: Bhavsan | last post by:
Here is what I am trying to do. Kindly, help me. 1. I'm creating a query dynamically based on User input using VBA (strSQL and DotSQL in the code below) 2. Executing the created query with in VBA...
5
by: joe donnelly | last post by:
I have a couple of questions about recordsets: 1. When a recordset is summoned by the code where does it actually exist and in what form...is it created in the database (data source location)...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.