C'est quoi l'erreur d'exécution 8577 sous vb 6.0

Signaler
-
 ima -
Bonjour,

quand je clique sur le bouton imprimer d'une application sous vb 6.0 que je suis entraine de faire des modifications j'obtient le message d'erreur suivant : erreur d'exécution 8577 : le texte de la commande de mise en forme des données comporte une erreur de syntaxe à la position 220 de la commande, ou a proximité de celle ci.le texte de commande à proximité de l'erreur est Courriers RELATE) AS COURRIERS
merci pour une aide.
voici le code :
Private Sub Cmd_imprime_Click()

If Lbl_Num_Borderau.Caption = "" Or Combo_dest.Text = "" Or (DataGrid_apercu.ApproxCount = 0 And Combo_type_brd.ListIndex <> 3) Then
msg = "Aucun bordereau séléctionné !"
Style = vbCritical + vbOKOnly
Title = "Impression impossible"
Response = MsgBox(msg, Style, Title, "Demo.hlp", 1000)
Exit Sub
End If

Select Case Combo_type_brd.ListIndex

Case 0:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport1.Refresh
DataEnvironment1.rsborderau.Close


DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open '1904
DataReport1.Refresh
DataEnvironment1.rsborderau.Close


DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open '1904
DataReport1.Refresh

Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport1.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption

'" / " & Nbr_Brd_Dest_And_Type & " " & Lbl_num_brd_apercu.Caption
DataReport1.Refresh
On Error GoTo passerimpression1
DataReport1.PrintReport
'pour que la forme reste active
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression1:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct

Case 1:
If PremiereImpression = True Then

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport2.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport2.Refresh
DataEnvironment1.rsborderau.Close


DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport2.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

'DataReport2.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
'DataEnvironment1.rsborderau.Open '1904
'DataReport2.Refresh
On Error GoTo passerimpression2
DataReport2.PrintReport
'pour que la forme reste active
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression2:
'DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct


Case 2:
If PremiereImpression = True Then

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport3.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh
DataEnvironment1.rsborderau.Close


DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh

Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport3.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption

DataReport3.Refresh

On Error GoTo passerimpression3
DataReport3.PrintReport

'pour que la forme reste active
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression3:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct

Case 3:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport4.Refresh
DataEnvironment1.rsborderau.Close


DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport4.Refresh
On Error GoTo passerimpression4
DataReport4.PrintReport
Unload DataReport4

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression4:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct

Case 4:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport5.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport5.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
DataReport5.Refresh
On Error GoTo passerimpression5
DataReport5.PrintReport
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression5:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct

fnslct:
End Select
End Sub

4 réponses

rebonjour,
désolée pour le code.
Private Sub Cmd_imprime_Click() 
If Lbl_Num_Borderau.Caption = "" Or Combo_dest.Text = "" Or (DataGrid_apercu.ApproxCount = 0 And Combo_type_brd.ListIndex <> 3) Then
msg = "Aucun bordereau séléctionné !"
Style = vbCritical + vbOKOnly
Title = "Impression impossible"
Response = MsgBox(msg, Style, Title, "Demo.hlp", 1000)
Exit Sub
End If
Select Case Combo_type_brd.ListIndex
Case 0:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport1.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open '1904
DataReport1.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open '1904
DataReport1.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport1.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
'" / " & Nbr_Brd_Dest_And_Type & " " & Lbl_num_brd_apercu.Caption
DataReport1.Refresh
On Error GoTo passerimpression1
DataReport1.PrintReport
'pour que la forme reste active
Form1.ZOrder 0
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression1:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 1:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport2.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport2.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport2.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART],Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
'DataReport2.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
'DataEnvironment1.rsborderau.Open '1904
'DataReport2.Refresh
On Error GoTo passerimpression2
DataReport2.PrintReport
'pour que la forme reste active
Form1.ZOrder 0
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression2:
'DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 2:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport3.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport3.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
DataReport3.Refresh
On Error GoTo passerimpression3
DataReport3.PrintReport
'pour que la forme reste active
Form1.ZOrder 0
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression3:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 3:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport4.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport4.Refresh
On Error GoTo passerimpression4
DataReport4.PrintReport
Unload DataReport4
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close
passerimpression4:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 4:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport5.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport5.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
DataReport5.Refresh
On Error GoTo passerimpression5
DataReport5.PrintReport
Form1.ZOrder 0
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression5:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
fnslct:
End Select
Messages postés
18038
Date d'inscription
lundi 7 décembre 2009
Statut
Modérateur
Dernière intervention
11 avril 2018
233
Bonjour,
cette erreur est une erreur de commande/requête
Tu n'as pas présenté ton code entre balises code et il est donc pénible à suivre.
Il semble que tu veuilles travailler avec des jeux d'enregistrements hiérarchiques ===>> A lire, donc :
https://support.microsoft.com/en-us/kb/189657

EDIT : et c'est sans compter le fait que l'on ne voit rien, dans ton code (il est vrai difficile à suivre sans les balises code), concernant de près ou de loin la chaîne de connexion à une base de données ni (si tu utilises un report), un éventuel datasource !
Avec çà ===>> erreur d'exécution bien évidemment possible à différents et multiples niveaux !

________________________
Nul ne saurait valablement coder ce qu'il ne saurait exposer clairement.
Messages postés
18038
Date d'inscription
lundi 7 décembre 2009
Statut
Modérateur
Dernière intervention
11 avril 2018
233
Regarde le code montré : il est maintenant mis entre balises, mais il n'est pas indenté et donc pas plus lisible que le premier "jus" !

EDIT : je constate que "soussie" a moins de difficultés à présenter un code entre balises et indenté que n'en rencontre "ima". Pourquoi ?

Veux-tu que je te montre celui que "soussie" a présenté "ailleurs" ? ===>>
 Private Sub Cmd_imprime_Click()

If Lbl_Num_Borderau.Caption = "" Or Combo_dest.Text = "" Or (DataGrid_apercu.ApproxCount = 0 And Combo_type_brd.ListIndex <> 3) Then
msg = "Aucun bordereau séléctionné !"
Style = vbCritical + vbOKOnly
Title = "Impression impossible"
Response = MsgBox(msg, Style, Title, "Demo.hlp", 1000)
Exit Sub
End If

Select Case Combo_type_brd.ListIndex
Case 0:
If PremiereImpression = True Then

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"

DataEnvironment1.rsborderau.Open
DataReport1.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open 'ajouté
DataReport1.Refresh
DataEnvironment1.rsborderau.Close

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open 'ajouté
DataReport1.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport1.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption

DataReport1.Refresh

On Error GoTo passerimpression1

DataReport1.PrintReport
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression1:
DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 1:
If PremiereImpression = True Then

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport2.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"


' DataReport2.Refresh
' DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport2.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport2.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
'DataEnvironment1.rsborderau.Open 'ajouté
DataReport2.Refresh
On Error GoTo passerimpression2
DataReport2.PrintReport
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression2:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 2:
If PremiereImpression = True Then

DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport3.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport3.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport3.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
DataReport3.Refresh
On Error GoTo passerimpression3
DataReport3.PrintReport
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression3:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct

Case 3:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport4.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport4.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If
DataReport4.Refresh
On Error GoTo passerimpression4
DataReport4.PrintReport
Unload DataReport4

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression4:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
Case 4:
If PremiereImpression = True Then
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataEnvironment1.rsborderau.Open
DataReport5.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
DataEnvironment1.rsborderau.Close
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
DataReport5.Refresh
Else
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'} AS borderau APPEND ({Select * from Courriers, Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre} AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"
End If

DataReport5.Title = Lbl_ref_apercu.Caption & " " & Lbl_date_dp_apercu.Caption & " " & Lbl_localite_apercu.Caption & "-" & Lbl_dest_apercu.Caption & " " & Lbl_num_brd_apercu.Caption
DataReport5.Refresh
On Error GoTo passerimpression5
DataReport5.PrintReport
Form1.ZOrder 0

requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
rsBrdImp.Update
rsBrdImp.Close
passerimpression5:

DataEnvironment1.rsborderau.Close
PremiereImpression = False
GoTo fnslct
fnslct:
End Select
End Sub

Voilà qui est fait. Etrange, non ?
Cela n'enlève ni n'ajoute absolument rien à ce que je t'ai dit plus haut.
________________________
Nul ne saurait valablement coder ce qu'il ne saurait exposer clairement.
re,
soussie c ima c toujours mon code.
je poste sur plusieurs forum pour pouvoir avoire une réponse
voulez vous dire que la source de l'erreur c'est ma requete :
DataEnvironment1.rsborderau.Source = "SHAPE {SELECT * from [BORDERAUX DEPART], Sites where cod_dest = cod_site AND cod_brd_dp= '" & Lbl_Num_Borderau.Caption & "'}AS borderau APPEND ({Select * from Courriers,Sites where Courriers.cod_exp = Sites.cod_site ORDER BY Courriers.ordre}AS Courriers RELATE 'cod_brd_dp' TO 'cod_brd_dp') AS Courriers"

ou bien :
requette = "SELECT * From [BORDERAUX DEPART] WHERE cod_brd_dp = '" & Lbl_Num_Borderau.Caption & "'"
Set rsBrdImp = base.OpenRecordset(requette)
rsBrdImp.Edit
rsBrdImp!imp = True
'rsBrdImp.type_print = Nbr_Brd_Dest_And_Type
rsBrdImp.Update
rsBrdImp.Close