Access ADO parameter query



I have a form with a text box and button and want to run an Access
query that takes an input parameter.
I have the following code for the button:
I get an error at the line where the arrow is pointed
requested operation requires an OLE DB Session object, which is not
supported by the current provider

Private Sub Command1_Click()
Dim prm0 As ADODB.Parameter
Dim cnn As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim rst1 As ADODB.Recordset
Dim s1 As String
s1 = Text1.Text

cnn = Application.CurrentProject.Connection
cmd1.CommandType = adCmdText
cmd1.CommandText = "Select * from qryOrderInfoByCountry Where country

Set prm0 = cmd1.CreateParameter("prmCountry", adVarChar,
adParamInput, 15)
prm0.Value = s1

cmd1.Parameters.Append prm0
Set cmd1.ActiveConnection = cnn <------

Set rst1 = cmd1.Execute
MsgBox rst1!city
End Sub

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question