Passing parameter to a query in VBA (ADO)
From: Chuck (no.address_at_no.where)
Date: 04/06/04
- Next message: Rick Brandt: "Re: Multi Select Combo Box"
- Previous message: Brad: "Re: Sending emails from Access"
- Next in thread: Gerald Stanley: "Re: Passing parameter to a query in VBA (ADO)"
- Reply: Gerald Stanley: "Re: Passing parameter to a query in VBA (ADO)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 6 Apr 2004 08:36:35 -0400
I need to pass two parameters to a query using ADO. The only way I could
get it to work is by using the code below where "Set prm =
cmd.CreateParameter" is used once for each parameter. I'm not sure if this
is necessary so any insight would be appreciated. Thanks
Set rst= New ADODB.Recordset
rst.CursorLocation = adUseClient
Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = My_SQL_String
Set prm = cmd.CreateParameter
prm.Type = adChar
prm.Size = 25
cmd.Parameters.Append prm
cmd.Parameters(0).Value = Me!My_Control_1
Set prm = cmd.CreateParameter
prm.Type = adInteger
prm.Size = 5
cmd.Parameters.Append prm
cmd.Parameters(1).Value = Me!My_Control_2
rst.Open cmd
- Next message: Rick Brandt: "Re: Multi Select Combo Box"
- Previous message: Brad: "Re: Sending emails from Access"
- Next in thread: Gerald Stanley: "Re: Passing parameter to a query in VBA (ADO)"
- Reply: Gerald Stanley: "Re: Passing parameter to a query in VBA (ADO)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|