Kod:
Private Sub UserForm_Initialize()
Dim adoCN As Object
Dim RS As Object
Dim strSQL As String
Dim NoA As Long
DatabasePath = "deneme.mdb"
If Dir(DatabasePath) = "" Then
MsgBox DatabasePath & " bulunamadi, programdan cikilacak !", vbCritical, "ExcelToMDB"
Exit Sub
End If
Set adoCN = CreateObject("ADODB.Connection")
adoCN.Provider = "Microsoft.Jet.OLEDB.4.0"
adoCN.ConnectionString = DatabasePath
adoCN.Open
NoA = Cells(65536, 1).End(xlUp).Row
Set RS = CreateObject("ADODB.recordset")
strSQL = "SELECT * FROM [tbProje]"
RS.Open strSQL, adoCN, 1, 3
RS.MoveFirst
For i = 1 To RS.RecordCount
Sheets("Sheet1").Cells(i, 1).Value = RS("P_Satir1")
Sheets("Sheet1").Cells(i, 3) = RS("P_Durum")
Sheets("Sheet1").Cells(i, 8) = RS("P_Tarih")
RS.MoveNext
Next
RS.Close
adoCN.Close
Set RS = Nothing
end sub
ancak tüm veriler bana geliyor. ben ise hepsinin gelmesini istemiyorum.
access deki P_tarih sütündani tarihler şu formatta oluyor.
20080723
ben buna göre şu şekilde bi formül yaptım ama olmadı malesef.
bunu nasıl istediğim gibi yapabilirim.
Kod:
if mid(RS("P_Tarih"),1,4)>2007 then
RS.MoveFirst
For i = 1 To RS.RecordCount
Sheets("Sheet1").Cells(i, 1).Value = RS("P_Satir1")
Sheets("Sheet1").Cells(i, 3) = RS("P_Durum")
Sheets("Sheet1").Cells(i, 8) = RS("P_Tarih")
RS.MoveNext
Next i