Access datalarınıza bakabileceğiniz bir program.Geliştirmek sizlere kalmış kolay gelsin.
Not:2003 ve altı veri tabanlarını destekler.
Access Data Görüntüleme
Kod:
'Forma Eklenecek Kontroller
'1 Adet ComboBox Adı cmbDatabase Olacak
'1 " ListBox " dblist "
'1 " Datagrid1 " Datagrid1 "
'1 " CommondButon " cmdListele "
'1 " Adodc " Adodc1 "
'1 " CommonDialog " CommonDialog1 "
'1 " Module " Module1 "
'MODULE YAZILACAK KOD Buradan Başlıyor.
Public ADO As Object
Public recset As New ADODB.Recordset
Public dbFile As String
Public dbFile2 As String
Public Function ADOConnection(dbFile As String)
Set ADO = CreateObject("Adodb.Connection")
If ADO.State <> 0 Then ADO.Close
ADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbFile & ";Persist Security Info=False"
Set recset = ADO.OpenSchema(adSchemaTables)
Do While Not recset.EOF
If UCase(Left(recset.Fields("TABLE_NAME"), 4)) <> "MSYS" Then Form1.dblist.AddItem (recset.Fields("TABLE_NAME"))
recset.MoveNext
Loop
End Function
Public Function CenterScreen(frmform As Form)
frmform.Left = (Screen.Width - frmform.Width) / 2
frmform.Top = (Screen.Height - frmform.Height) / 2
End Function
'Module Yazılacak Kod Burada Son Buluyor.
'FORMA YAZILACAK KOD Buradan Başlıyor.
Private Sub cmbDatabase_DropDown()
CommonDialog1.ShowOpen
cmbDatabase.Text = CommonDialog1.FileName
End Sub
Private Sub cmdListele_Click()
dblist.Clear
If CommonDialog1.FileName <> "" Then ADOConnection CommonDialog1.FileName
dbFile2 = CommonDialog1.FileName
End Sub
Private Sub dblist_Click()
With Adodc1
.ConnectionString = ADO
.CommandType = adCmdText
.RecordSource = "Select * From " & Me.dblist.Text & ""
Set Datagrid1.DataSource = Adodc1
.Refresh
End With
Exit Sub
End Sub
Private Sub Form_Load()
With Adodc1
.ConnectionString = dbFile
.CommandType = adCmdText
End With
CenterScreen Me
End Sub
Kod:
Private Sub cmdYazdir_Click()
Call GridPrint(Datagrid1)
End Sub
Public Sub GridPrint(gridQuery As DataGrid)
Dim I As Integer
Dim J As Integer
Dim PTab As Integer
For I = 0 To gridQuery.ApproxCount - 1
PTab = 20
If Printer.CurrentY + Printer.TextHeight(gridQuery.Text) > Printer.ScaleHeight - 0 Then
Printer.NewPage
End If
On Error Resume Next
gridQuery.Row = I
On Error GoTo 0
For J = 0 To gridQuery.Columns.Count - 1
gridQuery.Col = J
Printer.Print Trim$(gridQuery.Text); Tab(PTab);
PTab = PTab + 20
Next
Printer.Print
Next
Printer.EndDoc
End Sub