I'm not very familiar with Access and I'm learning vba in =Excel.
Here's what I want to do:
Copy a column of text in Excel
Open an access DB and replace existing items in table with copied data
Open a query and copy and paste the results back into Excel
I'm doing this through an ActiveX macro activated with a button click.
I'm using office 07 but the DB is in 02-03 file format, if this makes a difference.
My code stops running at the line: .DoCmd.RunComma nd acCmdSelectAll and from examples I've seen online I thought this would work. Could you tell me what I'm doing wrong? Thanks.
Here's my code:
ActiveSheet.Ran ge("A1:A" & ActiveCell.Row) .Copy
ActiveSheet.Ran ge("A1").Selec t
' This section retrieves the Vendor Data from the Database
Dim FilePath As String
Dim AccDatabase As Object
Dim counter As Integer
FilePath = "C:\Personal\Ma cros\PartSuppli er.mdb"
Set AccDatabase = CreateObject("A ccess.Applicati on")
With AccDatabase
.Visible = True 'Will change to False when macro works
.OpenCurrentDat abase FilePath
.DoCmd.OpenTabl e "tblFindPar ts"
.DoCmd.SetWarni ngs False
.DoCmd.RunComma nd acCmdSelectAll
.DoCmd.RunComma nd acCmdDelete
' Other code goess here to open query and copy and paste data
End With
Set AccDatabase = Nothing
Here's what I want to do:
Copy a column of text in Excel
Open an access DB and replace existing items in table with copied data
Open a query and copy and paste the results back into Excel
I'm doing this through an ActiveX macro activated with a button click.
I'm using office 07 but the DB is in 02-03 file format, if this makes a difference.
My code stops running at the line: .DoCmd.RunComma nd acCmdSelectAll and from examples I've seen online I thought this would work. Could you tell me what I'm doing wrong? Thanks.
Here's my code:
ActiveSheet.Ran ge("A1:A" & ActiveCell.Row) .Copy
ActiveSheet.Ran ge("A1").Selec t
' This section retrieves the Vendor Data from the Database
Dim FilePath As String
Dim AccDatabase As Object
Dim counter As Integer
FilePath = "C:\Personal\Ma cros\PartSuppli er.mdb"
Set AccDatabase = CreateObject("A ccess.Applicati on")
With AccDatabase
.Visible = True 'Will change to False when macro works
.OpenCurrentDat abase FilePath
.DoCmd.OpenTabl e "tblFindPar ts"
.DoCmd.SetWarni ngs False
.DoCmd.RunComma nd acCmdSelectAll
.DoCmd.RunComma nd acCmdDelete
' Other code goess here to open query and copy and paste data
End With
Set AccDatabase = Nothing
Comment