HELP-Can't open a Query recordset

  • Thread starter Ken Snell [MVP]
  • Start date
K

Ken Snell [MVP]

What you've posted is inadequate for anyone to take a guess as to what is
happening... there obviously must be a "With ..." statement above this code
step, but we can only guess what is in that With statement.

What type of recordset are you trying to open? What is all the code that is
involved? What is qryName's value? How does it get its value?
 
A

Alan Baker

9/1/2005



I am having difficulty opening a query recordset for analysis.

The following code opens the query with no problems when the query has
either no criteria or criteria specified as constants. When I attempt to put
a variable in the query criteria, it stops at the line



.Open qryName, Options:=adCmdTableDirect





with the Run Time Error that says "Too few parameters. Expected x" where x
is the number of variables specified in the criteria



Can you tell me what is wrong and how to fix it?



I will post this to a couple of newsgroups because I'm not sure which one is
appropriate.

If possible, please respond to me directly at (e-mail address removed). as I am
a newbie to these newsgroups.



Many many thanks.



Al Baker







Sub QueryTableLookup()



Const qryName As String = "qryVerifyDeleteRecords"



Dim rstqryEquipOne As ADODB.Recordset



Set rstqryEquipOne = New ADODB.Recordset

Set rstqryEquipOne.ActiveConnection = CurrentProject.Connection





With rstqryEquipOne

.CursorType = adOpenKeyset

.Open qryName, Options:=adCmdTableDirect

End With



DoCmd.OpenQuery qryName, acNormal, acEdit

rstqryEquipOne.MoveFirst



LastEquipId = rstqryEquipOne!ID





Stop

End
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top