Private Sub Form_Open(Cancel As Integer)
Dim SQL As String
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
If cnUtil.State <> adStateOpen Then
cnUtil.Open sDemelerChaine(sConnUtil)
End If
On Error GoTo Terminer
rst.CursorLocation = adUseClient
rst.CursorType = adOpenKeyset
' rst.Open SQL, cnUtil, adOpenKeyset
' SQL = "SELECT dbo.tbRechercheExperts.ID, dbo.tbRechercheExperts.NoRecherche, dbo.tbRechercheExperts.Initiales,dbo.tbRechercheExperts.NbBons, dbo.tbRechercheExperts.DateReponse,dbo.tbRechercheExperts.Statut, " & _
' " dbo.tbRechercheExperts.DateDemande, CASE WHEN FC.NoFiche IS NULL THEN H.Prénom + ' ' + H.Nom ELSE FC.PrénHomme + ' ' + FC.NomHomme END AS Homme," & _
' " CASE WHEN FC.NoFiche IS NULL THEN F.Prénom + ' ' + F.Nom ELSE FC.PrénFemme + ' ' + FC.NomFemme END AS Femme, CASE WHEN FC.NoFiche IS NULL" & _
' " THEN TypeRecherche ELSE 3 END AS Type" & _
' " FROM dbo.tbRechercheExperts LEFT OUTER JOIN" & _
' " [ma-arbres" & sSourceBD & "].dbo.tbPersonnes AS H ON dbo.tbRechercheExperts.NoHomme = H.NoPersonne LEFT OUTER JOIN" & _
' " [ma-arbres" & sSourceBD & "].dbo.tbPersonnes AS F ON dbo.tbRechercheExperts.NoFemme = F.NoPersonne LEFT OUTER JOIN" & _
' " [mesaieux" & sSourceBD & "].dbo.tbSiteFiches AS FC ON dbo.tbRechercheExperts.NoFiche = FC.NoFiche" & _
' " WHERE (dbo.tbRechercheExperts.ID = '" & Me.OpenArgs & "')"
With cmd
.ActiveConnection = cnUtil
.CommandType = adCmdStoredProc
.CommandText = "spRecherchesServClientele"
.Parameters.Append cmd.CreateParameter("@ID", adVarChar, adParamInput, 20, Me.OpenArgs)
Set rst = .Execute
End With
Set Me.Recordset = rst
Exit Sub
Terminer:
Cancel = True
End Sub
USE [ma-admin-01]
GO
/****** Object: StoredProcedure [dbo].[spRecherchesServClientele] Script Date: 10/06/2011 12:15:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[spRecherchesServClientele]
-- Add the parameters for the stored procedure here
@ID varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT dbo.tbRechercheExperts.ID, dbo.tbRechercheExperts.NoRecherche, dbo.tbRechercheExperts.Initiales,dbo.tbRechercheExperts.NbBons,
dbo.tbRechercheExperts.DateReponse,dbo.tbRechercheExperts.Statut,
dbo.tbRechercheExperts.DateDemande,
CASE WHEN tbRechercheExperts.NoFiche IS NULL THEN
CASE WHEN TypeRecherche IN (0, 1) THEN H.Prénom + ' ' + H.Nom
ELSE CASE E.Sexe WHEN 1 THEN E.Prénom + ' ' + E.Nom ELSE '' END
END
ELSE
CASE tbRechercheExperts.TypeRecherche WHEN 1 THEN FC.PrénHomme + ' ' + FC.NomHomme
WHEN 2 THEN CASE B.Sexe WHEN 1 THEN B.PrénEnfant + ' ' + B.NomEnfant ELSE '' END
WHEN 3 THEN CASE S.Sexe WHEN 1 THEN S.PrénDéfunt + ' ' + S.NomDéfunt ELSE '' END
END
END AS Homme,
CASE WHEN tbRechercheExperts.NoFiche IS NULL THEN
CASE WHEN TypeRecherche IN (0, 1) THEN F.Prénom + ' ' + F.Nom
ELSE CASE E.Sexe WHEN 0 THEN E.Prénom + ' ' + E.Nom ELSE '' END
END
ELSE
CASE tbRechercheExperts.TypeRecherche WHEN 1 THEN FC.PrénFemme + ' ' + FC.NomFemme
WHEN 2 THEN CASE B.Sexe WHEN 0 THEN B.PrénEnfant + ' ' + B.NomEnfant ELSE '' END
WHEN 3 THEN CASE S.Sexe WHEN 0 THEN S.PrénDéfunt + ' ' + S.NomDéfunt ELSE '' END
END
END AS Femme,
CASE WHEN tbRechercheExperts.NoFiche IS NULL THEN CASE WHEN TypeRecherche BETWEEN 1 AND 3 THEN 1 ELSE 0 END ELSE 2 END AS TypeRecherche,
CASE WHEN TypeRecherche IN (0, 1) THEN 'M' WHEN TypeRecherche IN (2, 4) THEN 'B' ELSE 'S' END AS TypeActe
FROM dbo.tbRechercheExperts
LEFT OUTER JOIN [ma-arbres-01].dbo.tbPersonnes AS H ON dbo.tbRechercheExperts.NoHomme = H.NoPersonne
LEFT OUTER JOIN [ma-arbres-01].dbo.tbPersonnes AS F ON dbo.tbRechercheExperts.NoFemme = F.NoPersonne
LEFT OUTER JOIN [ma-arbres-01].dbo.tbPersonnes AS E ON dbo.tbRechercheExperts.NoEnfant = E.NoPersonne
LEFT OUTER JOIN [mesaieux-01].dbo.tbSiteFiches AS FC ON dbo.tbRechercheExperts.NoFiche = FC.NoFiche
LEFT OUTER JOIN [ma-bs-01].dbo.tbSiteBaptemes AS B ON dbo.tbRechercheExperts.NoFiche = B.NoActe
LEFT OUTER JOIN [ma-bs-01].dbo.tbSiteSepultures AS S ON dbo.tbRechercheExperts.NoFiche = S.NoActe
WHERE (dbo.tbRechercheExperts.ID = @ID)END
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
/*
commented code
goes here
*/
Preece