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 do I execute an sql script via the command prompt?
How to I get a contact us page with forms to send information
sp3 will not update
Sharepoint 2007 Date/Time Setting on bottom of Pages is incorrect
Check to see if a column name in a linked table has changed
What is the best way to walk through a DataSource of a DevExpress XtraGrid to see if there are any duplicate values in the rows?
Access 2007 VBA Report onFormat ignored on open
What is the difference between a MSI and MST file.?
Difference between Vmware player and Vmware server.
maxclient Id from table