1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| 'On Error GoTo err_Continue_Click
Dim db As Database, qry As QueryDef, qryName As String, errCause As String
Dim sql As String
Dim stdocname As String
Set db = CurrentDb
errCause = "owen"
qryName = "Q_append_country_to_mission"
stdocname1 = "F_enter_participant"
stdocname2 = "F_enter_country"
sql = "INSERT INTO Country_beneficiary_mission ( Country_code, Mission_key )" _
& " SELECT Country.Country_code, Last(Mission.Mission_key) AS LastOfMission_key" _
& " FROM Country, Mission" _
& " GROUP BY Country.Country_code" _
& " HAVING (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo2) & Chr(34) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo4) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo6) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo8) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo10) Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo12) _
sql = sql & " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo14) & Chr(13) & Chr(10) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo16) & Chr(13) & Chr(10) _
& " Or (Country.Country_code" & Chr(34) & chkTrim(Me.Combo18) & Chr(13) & Chr(10) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo20) & Chr(13) & Chr(10) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo22) & Chr(13) & Chr(10) _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo24) & Chr(13) & Chr(10)
sql = sql & " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo26) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo28) Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo30) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo32) & Chr(13) & Chr(10)" _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo34) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo36) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo38) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo40) & Chr(13) & Chr(10)" _
& " Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo42) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo44) Or (Country.Country_code)=" & Chr(34) & chkTrim(Me.Combo46) Or (Country.Country_code) = " & Chr(34) & chkTrim(Me.Combo48)"
Dim itm As Variant
For Each itm In Me.Lstcountry.ItemsSelected
sql = sql & " Or (Country.Country_code)=" & Chr(34) & Me.Lstcountry.ItemData(itm) & Chr(34)
Next itm
sql = sql & ";"
Debug.Print sql
Set qry = db.CreateQueryDef("", sql)
qry.Execute dbFailOnError
' DoCmd.SetWarnings warningsoff
' DoCmd.OpenQuery qryName
' DoCmd.SetWarnings warningson
DoCmd.Close acForm, stdocname2, acSaveYes
DoCmd.OpenForm stdocname1, acNormal
exit_Continue_Click:
Exit Sub
err_Continue_Click:
MsgBox Err.Number & Err.Description
Resume exit_Continue_Click
End Sub |
Partager