Oleh: wawarhw | Februari 26, 2009

Sharing Informasi : Import data dari Excel ke Access dengan Visual Basic 6

 

Private Sub Command1_Click()
Dim Cn As ADODB.Connection
Dim i As Integer
Set Cn = New ADODB.Connection
Dim p As String

p = MsgBox(“apakah data yang akan di import sudah betul ?”, vbYesNo, Me.Caption)
If p = vbYes Then

Cn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & FileExcel & “;Extended Properties=Excel 8.0;” _
& “Persist Security Info=False”

Cn.Execute “INSERT INTO [tblpersonil] IN ‘C:\DATABASE\RHPP.mdb’ SELECT * FROM [Sheet1$]“

Cn.Close
Set Cn = Nothing
Else
MsgBox “tidak jadi di import,silahkan periksa lagi”
End If
End Sub

Private Sub Command2_Click()
CommonDialog1.DialogTitle = “Excel File”
CommonDialog1.Filter = “Excel (*.xls)|*.xls”
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowOpen
FileExcel = CommonDialog1.FileName
If FileExcel = “” Then Exit Sub
End Sub


Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Kategori

Ikuti

Get every new post delivered to your Inbox.