473,395 Members | 1,680 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.

Appoend Current Record To Several Tables


I have tried the following which errors out at rs.MoveLast.
Can anyone help me?
Please note I am not a programmer - but learning quickly :)
Kind regards
Bernard

Access 2003
Code attached to a command button on Form

Private Sub cmdAppendFrom351To_352_And_497_Click()
'Append data from Form\Table 0208351 into several other Tables

Dim rst As DAO.Recordset
Dim sSQL1 As String
Dim sSQL2 As String

'Only select the last record
rs.MoveLast

sSQL1 = "INSERT INTO 0208352 ( [Build Date], [Thermal Screening Record]
)" _
& " SELECT [0208351].[Build Date], [0208351].[Thermal Screening Record]"
_
& " FROM 0208351;"

sSQL2 = "INSERT INTO 0208497 ( [Build Date], [Thermal Screening Record]
)" _
& " SELECT [0208351].[Build Date], [0208351].[Thermal Screening Record]"
_
& " FROM 0208351;"

DoCmd.RunSQL sSQL1
DoCmd.RunSQL sSQL2
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Sep 7 '07 #1
1 1477
On 07 Sep 2007 07:31:12 GMT, Bernard Elgar
<be****@allen-vanguard.co.ukwrote:

You can't use "rs.MoveLast" for so many reasons I won't list them.

Since you want to insert the last record from some table, use the
WHERE clause to ensure that:
sSQL1 = "INSERT INTO 0208352 ( [Build Date], [Thermal Screening
Record])" _
& " SELECT [0208351].[Build Date], [0208351].[Thermal Screening
Record]" _
& " FROM 0208351 WHERE <somefield>=<somevalue>;"

I don't understand your db design well enough to suggest values for
<somefieldand <somevalue>, but you get the drift.

Often it is easier to first create the append query in the query
window, then view the sql statement it represents and move that to
your code.

-Tom.

>
I have tried the following which errors out at rs.MoveLast.
Can anyone help me?
Please note I am not a programmer - but learning quickly :)
Kind regards
Bernard

Access 2003
Code attached to a command button on Form

Private Sub cmdAppendFrom351To_352_And_497_Click()
'Append data from Form\Table 0208351 into several other Tables

Dim rst As DAO.Recordset
Dim sSQL1 As String
Dim sSQL2 As String

'Only select the last record
rs.MoveLast

sSQL1 = "INSERT INTO 0208352 ( [Build Date], [Thermal Screening Record]
)" _
& " SELECT [0208351].[Build Date], [0208351].[Thermal Screening Record]"
_
& " FROM 0208351;"

sSQL2 = "INSERT INTO 0208497 ( [Build Date], [Thermal Screening Record]
)" _
& " SELECT [0208351].[Build Date], [0208351].[Thermal Screening Record]"
_
& " FROM 0208351;"

DoCmd.RunSQL sSQL1
DoCmd.RunSQL sSQL2
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Sep 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robin S. | last post by:
More clueless newbie questions... Table 1: "available specs" Table 2: "classes" A single form shows a single record from the table "classes". Each record in "classes" may contain several...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
1
by: Neil | last post by:
When creating history tables that are appended to whenever a record is updated, should one append the corresponding child table records to their history tables at the same time (so as to have a...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
2
by: adwest | last post by:
Forgive me if this is a foolish question. I "play" in Access and have only created a few rather simple relational databases. My knowledge and experience is limited. I have no formal training, just...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.