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
find the number of years
Error when updating from MS Money 2000 to MS Money 2008
T-SQL: calculate totals in SELECT statement witout GROUP BY
How do I control (set) printer properties programatically without the print dialog window?
Is there any free fast low level formatting tool.
Report Group Subtotals and Total
Access 2007 Error Message - "Setting for property too Long"
i need a program to send popup messages over my LAN network
OLK2007: Cannot update the appointment because the corresponding item in the folder you synchronised does not match this item
Access:subform starting on last record