Advertisement
stevennathaniel

MS Access : Membuat Report Berdasarkan Custom Filter

Mar 9th, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.92 KB | None | 0 0
  1. Imports System.Data.OleDb
  2.  
  3. Imports System.Data
  4.  
  5. Imports Access = Microsoft.Office.Interop.Access
  6.  
  7. Imports Microsoft.Office
  8.  
  9. Public Class Form5
  10.  
  11.     Dim oledbKoneksi As OleDbConnection = New OleDbConnection
  12.  
  13.     Dim oledbPerintah As OleDbCommand = New OleDbCommand
  14.  
  15.     Dim lokasiFile As String = "D:\fileAccess\"
  16.  
  17.     Dim namaFile As String = "Database1.accdb"
  18.  
  19.     Dim stringKoneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & lokasiFile & namaFile & ";" & "Persist Security Info=False;"
  20.  
  21.     Dim adapter As New OleDbDataAdapter
  22.  
  23.     ' Dim nomerID As String = CStr(TextBox1.Text)
  24.  
  25.  
  26.     Sub tampilIsiGrid()
  27.  
  28.         oledbKoneksi.ConnectionString = stringKoneksi
  29.  
  30.         oledbKoneksi.Open()
  31.  
  32.         oledbPerintah.Connection = oledbKoneksi
  33.  
  34.         'oledbPerintah.CommandText = "SELECT * FROM kueriDataPembelian WHERE idpembelian = 'DPL0001'"
  35.  
  36.         oledbPerintah.CommandText = "SELECT * FROM kueriDataPembelian"
  37.  
  38.         adapter.SelectCommand = oledbPerintah
  39.  
  40.         Dim ds As DataSet
  41.  
  42.         ds = New DataSet
  43.  
  44.         adapter.Fill(ds)
  45.  
  46.         DataGridView1.DataSource = ds.Tables(0)
  47.  
  48.         oledbKoneksi.Close()
  49.  
  50.     End Sub
  51.  
  52.     Private Sub Form5_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  53.  
  54.         tampilIsiGrid()
  55.  
  56.  
  57.     End Sub
  58.  
  59.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  60.  
  61.  
  62.         ' nomerID = CStr(TextBox1.Text)
  63.         Dim nomerID As String = CStr(TextBox1.Text)
  64.  
  65.         Dim MSA As New Access.Application
  66.  
  67.         MSA.Visible = True
  68.  
  69.         MSA.OpenCurrentDatabase("D:\fileAccess\Database1.accdb")
  70.  
  71.         ' MSA.Application.DoCmd.OpenReport("reportDataPembelian2", Access.AcView.acViewPreview, "idpembelian = " & nomerID)
  72.  
  73.         MSA.Application.DoCmd.OpenReport("reportDataPembelian2", Access.AcView.acViewPreview, , "idpembelian =  '" & nomerID & "'")
  74.  
  75.     End Sub
  76. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement