MS Access Insert Into Slow for Large Recordset (VBA)

前端 未结 2 855
悲&欢浪女
悲&欢浪女 2021-01-24 16:16

I have a section of code which creates a new table and then attempts to copy the record set values into the table. The only problem is this it is quite slow and access shows the

2条回答
  •  余生分开走
    2021-01-24 16:40

    For multiple inserts in a loop, don't use SQL INSERT statements. Instead use a DAO.Recordset with .AddNew.

    See this answer: https://stackoverflow.com/a/33025620/3820271

    As positive side effects, your code will become better readable and you don't have to deal with the multiple formats for different data types.

    For Each field In RecordSet1.Fields
         rsTarget(field.Name) = field.Value
    Next field
    

提交回复
热议问题