and the module that contains my GetAppendSQL is as follows,
I have not changed anything as you told me not to...
Code:
Option Compare Database Private Function GetAppendSQL(strFrom As String, strTo As String) As String Dim strField As String Dim dbvar As DAO.Database Dim fldVar As DAO.Field Dim flsFrom As DAO.Fields, flsTo As DAO.Fields Set dbvar = CurrentDb() Set flsFrom = dbvar.TableDefs(strFrom).Fields Set flsTo = dbvar.TableDefs(strTo).Fields On Error Resume Next For Each fldVar In flsFrom 'Reset each time for test strField = "" 'This next line will fail if named field not present. strField = flsTo(fldVar.Name).Name If strField > "" Then _ GetAppendSQL = GetAppendSQL _ & Replace(", [%N] L ", "%N", strField) Next fldVar If GetAppendSQL = "" Then Exit Function GetAppendSQL = Replace("INSERT INTO [%F]%L" _ & " ( %N )%L" _ & "SELECT %N%L" _ & "FROM [%T]" _ , "%N", Mid(GetAppendSQL, 3)) GetAppendSQL = Replace(GetAppendSQL, "%F", strFrom) GetAppendSQL = Replace(GetAppendSQL, "%T", strTo) GetAppendSQL = Replace(GetAppendSQL, "%L", vbNewLine) End Function
Comment