daffelito 0 Newbie Poster

Hi, i have a problem with SQL, im verry new to it and in the beginner guides and tutorial you can't learn anything of the special tricks.

I have developed a Access db, and i need to use the INSERT INTO statement to insert the current record id of a table to an other table.

How do i write it?

now it looks like this:

Private Sub Kommandoknapp55_Click()
On Error GoTo Err_Kommandoknapp55_Click

Dim x As Integer
Dim strsql As String

DoCmd.GoToRecord , , acNewRec

here i need to use INSERT INTO to add the current table primary key into the second table

    For x = 0 To Listruta53.ListCount
    If Listruta53.Selected(x) = True Then
    strsql = "INSERT INTO tblPumpsortEl (El) Values ('" & Listruta53.Column(0, x) & "')"

    CurrentDb.Execute strsql, dbFailOnError

    End If
    Next x



Exit_Kommandoknapp55_Click:
    Exit Sub

Err_Kommandoknapp55_Click:
    MsgBox Err.Description
    Resume Exit_Kommandoknapp55_Click

End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.