0

My question was deleted because of duplicate but this is not the case. My example uses an already made sql-string. The answer SO does not and where SO is referring to is way to complicated to implement in my solution. I try to edit my post and be more clearly about my issue. So I have a form which connects to an external database. My query qry_LIMS selects the relevant data.

    LIDNUMMER = "([LIDNUMMER] = " & LIDNUMMER_Integer & ")"
    MONSTERTYPE = "([MONSTERTYPE] = '" & Monstertype_String & "')"
    MONSTERNDATUM = "([MONSTERNDATUM] = '" & Datum_String & "')"

    
    strCriteria = LIDNUMMER & "And" & MONSTERTYPE & "And" & MONSTERNDATUM
    
    task = "Select * from qry_LIMS where (" & strCriteria & ")"

    Me.Form.RecordSource = task

What is the most easy way to insert all records from task into an other table named tbl_LIMS?

The named fields of my table tbl_LIMS are the same as qry_LIMS:

Lidnummer
Monstertype
Monsterndatum

I think the solution would rather easy but I do not seem to get it

INSERT INTO tbl_LIMS VALUES (task)
  • I've linked an additional question, it's just `CurrentDb.Execute "INSERT INTO tbl_LIMS " & task`. Note that the columns need to match exactly (including primary keys, and not creating invalid ones) – Erik A Dec 16 '21 at 15:38
  • Thanks Erik A, I got it working with some minor adjustments: insertString = "INSERT INTO tbl_LIMS Select * FROM qry_LIMS where (" & strCriteria & ")" CurrentDb.Execute (insertString) – Mark Bakker Dec 16 '21 at 16:08

0 Answers0