bir modul oluşturup modulümüze bu kodu yazalım
Public Function SQLProsedur(Formx As Form, SQL_Prosedur As String)
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sorgu1 As String
Set cn = New ADODB.Connection
sorgu1 = SQL_Prosedur
cn.ConnectionString = verinedir()
cn.Open
rst.CursorLocation = adUseClient
rst.Open sorgu1, cn, adOpenKeyset, adLockOptimistic
Set Formx.Recordset = rst
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Function
bu da formda yada düğmede kullanma şekli
Private Sub Form_Open(Cancel As Integer)
Dim SQLProsedur1 As String
SQLProsedur1 = "EXECUTE [dbo].[cari_ekstre] '" & [Forms]![Extre Rapor]![Liste29] & "','" & _
Format([Forms]![Extre Rapor]![ILK], "mm.dd.yyyy") & "','" & Format([Forms]![Extre Rapor]![SON], "mm.dd.yyyy") & "'"
Call SQLProsedur(Form, SQLProsedur1)
End Sub
Public Function SQLProsedur(Formx As Form, SQL_Prosedur As String)
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sorgu1 As String
Set cn = New ADODB.Connection
sorgu1 = SQL_Prosedur
cn.ConnectionString = verinedir()
cn.Open
rst.CursorLocation = adUseClient
rst.Open sorgu1, cn, adOpenKeyset, adLockOptimistic
Set Formx.Recordset = rst
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Function
bu da formda yada düğmede kullanma şekli
Private Sub Form_Open(Cancel As Integer)
Dim SQLProsedur1 As String
SQLProsedur1 = "EXECUTE [dbo].[cari_ekstre] '" & [Forms]![Extre Rapor]![Liste29] & "','" & _
Format([Forms]![Extre Rapor]![ILK], "mm.dd.yyyy") & "','" & Format([Forms]![Extre Rapor]![SON], "mm.dd.yyyy") & "'"
Call SQLProsedur(Form, SQLProsedur1)
End Sub

