Solved

MS Access Open recordset does not handle dashes

Posted on 2014-12-12
5
259 Views
Last Modified: 2014-12-12
Why does MS Access handle Set rs = CurrentDB.OpenRecordset("qsReindeeers"), but it does not handle Set rs = CurrentDB.OpenRecordset("qs-Reindeeers")

I get too few parameters error...

How can I get MS Access to play nice with dashes ?
0
Comment
Question by:upobDaPlaya
  • 2
  • 2
5 Comments
 

Author Comment

by:upobDaPlaya
ID: 40497517
Actually the name is not the issue..I have 2 parameters within the query that properly reference the main and sub form, thus I am confused on why it does not work...  The code is called from within the main form/private sub via a command button
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40497519
Set rs = CurrentDB.OpenRecordset("qs-Reindeeers")

will just do fine..

try doing a compact and repair
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 400 total points
ID: 40497520
I get too few parameters error...

It is not the dashes that is the problem.
qsReindeeers is not the same query as qs-Reindeeers, is it?
qs-Reindeeers contains a parameter in the query.

You cannot open it that way.
You must open a QueryDef object. (qdf)
Then you must supply a correct value for the parameter.
Then you open the recordset
Set rs = qdf.OpenRecordset
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 100 total points
ID: 40497523
the problem is the query referenced to the subform is not correct

post the sql of the query
0
 

Author Closing Comment

by:upobDaPlaya
ID: 40497533
Query Def worked great..was not aware that a parameter query will not work in VBA unless I use qdef...thx !
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now