I am trying something that has been done hundreds of times - except my code does not compile. Using this as a reference How to do INSERT into a table records extracted from another table I came up with the following sub, that is supposed to clear a table and refill it from another linked table (The idea is to liberate the linked table so it doesn't have a .laccdg file in its name for long)
Private Sub Form_Open(Cancel As Integer)
Dim rsDocs As Recordset
Dim sqlQuery As String
DoCmd.RunSQL "DELETE * FROM [Docs]"
sqlQuery = "INSERT INTO [Docs] (Numero, Description, [ID Symix], Groupe, [ID Sami])" & _
" SELECT [Unité] & "" "" & [Numéro Document] AS Numero, Description, [ID Symix], [Groupe Source], [ID Doc Sami]" & _
" FROM [Documents]"
Debug.Print sqlQuery
Set rsDocs = CurrentDb.OpenRecordset(sqlQuery)
CurrentDb.Execute sqlQuery
rsDocs.Close
Set rsDocs = Nothing
End Sub
I get an error on the execute line. The sql statement is wrong. Can someone see where it falters? Is the use of "" "" to join two fields together acceptable in this situation?
Also, clearing the table prompts a message asking if i am sure i want to do this. Will setting DisplayAlerts to False have negative consequences? Or should it be harmless if I put it back to True right after?