1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Dim sSQL As String
sSQL = "INSERT INTO table1 " & _
"SELECT Table1.ID AS ID, Table1.[Study number] AS [Study number], Table1.[Study title] AS [Study title]," & _
"Table1.[Study management] AS [Study management], Table1.Sponsor AS Sponsor, Table1.[Amount of first payment] AS [Amount of first payment]," & _
" Table1.[1st payment-Approval date] AS [1st payment-Approval date], Table1.Status1 AS Status1, Table1.[Amount of second payment] AS [Amount of second payment], Table1.[2nd payment-Approval date] AS [2nd payment-Approval date], Table1.Status2 AS Status2, Table1.[Amount of third payment] AS [Amount of third payment], Table1.[3rd payment-Approval date] AS [3rd payment-Approval date], Table1.Status3 AS Status3, Table1.[Amount of fourth payment] AS [Amount of fourth payment], Table1.[4th payment-Approval date] AS [4th payment-Approval date], Table1.Status4 AS Status4, Table1.[Amount of fifth payment] AS [Amount of fifth payment], Table1.[5th payment-Approval date] AS [5th payment-Approval date], Table1.Status5 AS Status5, Table1.[Supplementary study cost] AS [Supplementary study cost]," & _
" Table1.[Supplementary cost-Approval date] AS [Supplementary cost-Approval date], Table1.Status AS Status, Table1.[Already payed] AS [Already payed], Table1.[Total study cost] AS [Total study cost] " & _
"FROM Table1 " & _
"WHERE (((Table1.[Amount of first payment])>0) And ((Table1.[1st payment-Approval date])>#1/1/2007# And (Table1.[1st payment-Approval date])<#1/1/2008#) And ((Table1.Status1)<>'Payed')) Or (((Table1.[Amount of first payment])>0) And (isnull(Table1.[1st payment-Approval date])) And " & _
"((Table1.Status1)<>'Payed')) Or (((Table1.[Amount of second payment])>0) And ((Table1.[2nd payment-Approval date])>#1/1/2007# And (Table1.[2nd payment-Approval date])<#1/1/2008#) And ((Table1.Status2)<>'Payed')) Or (((Table1.[Amount of second payment])>0) And " & _
"(isnull(Table1.[2nd payment-Approval date])) And ((Table1.Status2)<>'Payed')) Or (((Table1.[Amount of third payment])>0) And ((Table1.[3rd payment-Approval date])>#1/1/2007# And (Table1.[3rd payment-Approval date])<#1/1/2008#) And ((Table1.Status3)<>'Payed')) Or (((Table1.[Amount of third payment])>0) And (isnull(Table1.[3rd payment-Approval date])) And ((Table1.Status3)<>'Payed')) Or (((Table1.[Amount of fourth payment])>0) And ((Table1.[4th payment-Approval date])>#1/1/2007# " & _
"And (Table1.[4th payment-Approval date])<#1/1/2008#) And ((Table1.Status4)<>'Payed')) Or (((Table1.[Amount of fourth payment])>0) And (isnull(Table1.[4th payment-Approval date])) And ((Table1.Status4)<>'Payed')) Or (((Table1.[Amount of fifth payment])>0) And ((Table1.[5th payment-Approval date])>#1/1/2007# And (Table1.[5th payment-Approval date])<#1/1/2008#) And ((Table1.Status5)<>'Payed')) Or (((Table1.[Amount of fifth payment])>0) And (isnull(Table1.[5th payment-Approval date])) And ((Table1.Status5)<>'Payed')) Or (((Table1.[Supplementary study cost])>0) And ((Table1.[Supplementary cost-Approval date])>#1/1/2007# And (Table1.[Supplementary cost-Approval date])<#1/1/2008#) And ((Table1.Status)<>'Payed')) Or (((Table1.[Supplementary study cost])>0) And (isnull(Table1.[Supplementary cost-Approval date])) And ((Table1.Status)<>'Payed'));"
MsgBox Len(sSQL)
DoCmd.RunSQL sSQL |
Partager