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
How to determine Windows Version installed on a non-booting hard drive
Setting references in a new Access 2003 database using VBA
Excel paysheet
Delete with INNER JOINS
event viewer log error 17055 mssqlserver backup logs
Problem Upgrading a Child Domain to Windows 2008 R2
INSERT INTO new table from existing stored procedure
Can't boot from CD drive
formula disappear after converting from 2003 to 2007
How to detect mouse click on a line control?