Microsoft
Software
Hardware
Network
Question : Using ADO in VBA for Query with multiple parameters
I need to populate a recordset using ADO for a predefined MS Access Query. The query has four parameters relating to two query fields. THe first field is ContractID, six alphanumeric long defined as text. It must match a field on an open form (form1) or it must be Null. The second field is WS# number defined as Double. It must match a field on the same open form or be Null. Both fields must either match the open form fiields or both be Null. I need to move back and forth through the recordset so I need to use ADO (I know how to do this). I have been reading and reading and trying different code for two dalys now. "Need and example of ADO code that will work". Have tried the code below to just get it to read if one field matches but still no luck.
Dim strRecSrc As String, strCriteria, strCnn As String
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.parameter
strRecSrc = "Tqry_QuesAndAns"
Dim rs As ADODB.Recordset
Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = strRecSrc
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter
prm.Type = adVarWChar
prm.Size = 6
cmd.Parameters(0).Value = Forms![frm_SiteData]![Cont
ractID]
'Set prm = cmd.CreateParameter(WSprm,
adDouble, adParamInput)
'cmd.Parameters.Append prm
'cmd.Parameters(1).Value = Forms![frm_SiteData]![WS#]
rs.Open cmd
Answer : Using ADO in VBA for Query with multiple parameters
Where do you instantiate the recordset variable? I don't see a
Set rs = New ADODB.Recordset
line anywhere.
Random Solutions
Move priv1 to different drive on same server
WIndows 7 client in 2003 domain vbs logon script
Xbox 360 live wireless G vs N router
WSS 3.0 without Active Directory
calling oracle stored procedues from VC++ using ADO
Write Data to a Serial Port
Access 2003 delete buttons greyed out
vba code to go to a clear the content of a text box and move cursor to that text box
Search and replace text containing superscripts in Word
GPEDIT.MSC is missing