I am trying to append from a query to a table. The procedure checks a table, finds the value and goes and appends to the table found.
i liste the fields of the query and the fields of the table.. but something is wrong...
When my fields are numbers i put them in brackets?
IN this case i have three number fields and the rest are text.
Dim rs As DAO.Recordset
Dim strSQL As String
' mismatched
Set rs = CurrentDb.OpenRecordset("SELECT SOBP FROM Countries;")
Do While Not rs.EOF
'debit for normal case
DoCmd.SetWarnings (False)
strSQL = "INSERT INTO " & rs!SOBP & " (Org),(FACCT),(CSUB),(P/S),(SOBP),(Cntry),(debits)" &
" SELECT [Query1.Org],[Query1.FACCT],[Query1.CSUB],[Query1.P/S],[Query1.SOBP],[Query1.Cntry],[Query1.Debits] FROM Q_Normal WHERE trans='dr' and " & _
" [query2.sobp]='" & rs!SOBP & "';"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)
rs.MoveNext
Loop
thanks in advance
i liste the fields of the query and the fields of the table.. but something is wrong...
When my fields are numbers i put them in brackets?
IN this case i have three number fields and the rest are text.
Dim rs As DAO.Recordset
Dim strSQL As String
' mismatched
Set rs = CurrentDb.OpenRecordset("SELECT SOBP FROM Countries;")
Do While Not rs.EOF
'debit for normal case
DoCmd.SetWarnings (False)
strSQL = "INSERT INTO " & rs!SOBP & " (Org),(FACCT),(CSUB),(P/S),(SOBP),(Cntry),(debits)" &
" SELECT [Query1.Org],[Query1.FACCT],[Query1.CSUB],[Query1.P/S],[Query1.SOBP],[Query1.Cntry],[Query1.Debits] FROM Q_Normal WHERE trans='dr' and " & _
" [query2.sobp]='" & rs!SOBP & "';"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)
rs.MoveNext
Loop
thanks in advance