By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,560 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,560 IT Pros & Developers. It's quick & easy.

Appoend Current Record To Several Tables

P: n/a

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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.