slamet Harto
05-17-2009, 10:05 PM
Hi there,
I want to call an access macro to vba excell, please advise me what I'm doing wrong
Sub RunAccessMacro()
Dim appAccess As Object
Call Connect
Set appAccess = CreateObject("Access.Application")
With appAccess
Application.DisplayAlerts = False
.Open
.DoCmd.RunMacro "Update_data"
'.Quit
End With
Set appAccess = Nothing
End Sub
here is the connection code
Public Function Connect()
On Error GoTo Salah
Set Cn = New ADODB.Connection
Koneksi = "Driver={Microsoft Access Driver (*.mdb)}; dbq=" & glob_sdbPath & _
";uid=admin; pwd=abcd"
Cn.Open Koneksi
Sheets("MainMenu").Range("B2").Value = ""
Exit Function
Salah:
MsgBox "Connection to Database is Failed ! " _
& Chr(13) _
& Chr(13) _
& Chr(13) _
& "Please Contact Your System Administrator", vbCritical, MySecMsg
Sheets("MainMenu").Range("B2").Value = "Connection is Failed.."
Sheets("MainMenu").LogOutBtn.Enabled = False
Sheets("MainMenu").LogInBtn.Enabled = False
Sheets("MainMenu").EntryBtn.Enabled = False
Sheets("MainMenu").UpdateBtn.Enabled = False
Sheets("MainMenu").SearchBtn.Enabled = False
Sheets("MainMenu").ChgPwdBtn.Enabled = False
Sheets("MainMenu").ApptBtn.Enabled = 0: Sheets("MainMenu").ChgPwdBtn.Enabled = 0
End
End Function
I want to call an access macro to vba excell, please advise me what I'm doing wrong
Sub RunAccessMacro()
Dim appAccess As Object
Call Connect
Set appAccess = CreateObject("Access.Application")
With appAccess
Application.DisplayAlerts = False
.Open
.DoCmd.RunMacro "Update_data"
'.Quit
End With
Set appAccess = Nothing
End Sub
here is the connection code
Public Function Connect()
On Error GoTo Salah
Set Cn = New ADODB.Connection
Koneksi = "Driver={Microsoft Access Driver (*.mdb)}; dbq=" & glob_sdbPath & _
";uid=admin; pwd=abcd"
Cn.Open Koneksi
Sheets("MainMenu").Range("B2").Value = ""
Exit Function
Salah:
MsgBox "Connection to Database is Failed ! " _
& Chr(13) _
& Chr(13) _
& Chr(13) _
& "Please Contact Your System Administrator", vbCritical, MySecMsg
Sheets("MainMenu").Range("B2").Value = "Connection is Failed.."
Sheets("MainMenu").LogOutBtn.Enabled = False
Sheets("MainMenu").LogInBtn.Enabled = False
Sheets("MainMenu").EntryBtn.Enabled = False
Sheets("MainMenu").UpdateBtn.Enabled = False
Sheets("MainMenu").SearchBtn.Enabled = False
Sheets("MainMenu").ChgPwdBtn.Enabled = False
Sheets("MainMenu").ApptBtn.Enabled = 0: Sheets("MainMenu").ChgPwdBtn.Enabled = 0
End
End Function