By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,461 Members | 2,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,461 IT Pros & Developers. It's quick & easy.

Whats wrong with this piece of code II

P: n/a
It' me again. What I forgot to say, stops with a runtime error (insert,
delete, update or select expected; the error number is a very low number
starting with -).

I have another problematic code here:

Sub retrieve()
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim i, j As Integer

Set cmd = New ADODB.Command
Set prm = New ADODB.Parameter

cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "qryVintagerParam"

prm.Type = adInteger
prm.Direction = adParamInput
prm.Value = 2

cmd.Parameters.Append prm

Set rst = cmd.Execute(j, prm)

i = rst.RecordCount

MsgBox "Count: " & i
End Sub

Again, qryVintagerParam is predefined query. The definition includes a
parameter.

Thanks for your help!

Regards,
Jochen
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"asdf" <as**@asdf.com> wrote in news:3f89966e$0$234
$4*******@read.news.ch.uu.net:
cmd.ActiveConnection = CurrentProject.Connection


You forgot the "set" here. Connection is an object, not a string.

set cmd.ActiveConnection = CurrentProject.Connection
Nov 12 '05 #2

P: n/a
Success!

Thanks for this fast answer!
"Ross Presser" <rp******@NOSPAM.imtek.com.invalid> schrieb im Newsbeitrag
news:Xn**********************@129.250.170.91...
"asdf" <as**@asdf.com> wrote in news:3f89966e$0$234
$4*******@read.news.ch.uu.net:
cmd.ActiveConnection = CurrentProject.Connection


You forgot the "set" here. Connection is an object, not a string.

set cmd.ActiveConnection = CurrentProject.Connection

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.