RichardMGreen
Well-known Member
- Joined
- Feb 20, 2006
- Messages
- 2,177
Hi all
I've in middle of automating a database update for reporting.
I need to be able to run code (not a macro but actual VBA) in Access from within Excel.
This is what I have so far in Excel:-
When it gets to the conn.Execute line, I'm getting an error message which says:-
Command text was not set for the command object
Anyone any ideas where I'm going wrong?
I've in middle of automating a database update for reporting.
I need to be able to run code (not a macro but actual VBA) in Access from within Excel.
This is what I have so far in Excel:-
Code:
Sub test()
Dim conn As ADODB.Connection, rs As ADODB.Recordset, cmd As ADODB.Command, strConn As String
file = Sheets("General_Info").Range("A5").Value
Set conn = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & file & ";Persist Security Info=False;"
conn.ConnectionString = strConn
conn.Open
conn.Execute cmdRemove5PMFigures_Click (this is the name of the Access procedure)
Set cmd = New ADODB.Command
cmd.CommandType = adCmdText
cmd.ActiveConnection = conn
setcmd = Nothing
Set conn = Nothing
End Sub
When it gets to the conn.Execute line, I'm getting an error message which says:-
Command text was not set for the command object
Anyone any ideas where I'm going wrong?