Hi,
I have to append to a table (1A) only the last record of the table (2A).
I have written the following code but it doesn't work:
Private Sub Comando1_Click()
Dim db As Database
Set db = CurrentDb
Dim rst As Recordset
Set rst = db.OpenRecordset("2B", dbOpenDynaset)
rst.MoveLast
nr = rst.RecordCount
y = rst!CNT ' the CNT of the last record
MsgBox y
rst.Close
db.Close
Dim strSQLInsert As String
strSQLInsert = "Insert Into 1A (CNT,CITY,ZIP) SELECT CNT,CITY,ZIP FROM 2B WHERE CNT = y "
DoCmd.RunSQL strSQLInsert
end sub
If I use FROM 2B where cnt= 100" where 100 is the cnt of the last record everything is ok.
How can I assign the values of CNT to y in the strSQLinsert?
Can someone help me?
My best regards,
gimmy