Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Query Problem

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
0
0
US
In a query on which a report will be based I need to reference a PUBLIC variable in the GENERAL DECLARATIONS section.<br><br>However, every time I enter the Criteria in the query design and then try to run it, I get a 'Type Mismatch' error.<br><br>Variable is declared, in GENERAL DECLARATIONS, as<br><br>&nbsp;&nbsp;&nbsp;Public StartValue as Integer<br><br>Ideas GRATEFULLY accepted!<br><br>Thanks in advance.<br><br>Tom
 
I'm breaking my head over the same stupid problem. My problem is not also the criteria but how make a var ,inputed in a form, known in the query. Is it something with [$var] or any syntax combition, I realy can't find anyting of it in the help section
 
My work-around on this problem was to write a public function with no parameters which returned the current value of the public variable and then use the function in the query.<br><br>The good news about this, as I found trying to generate a random column using the Rnd() function, is that the engine seems only to evaluate a function with no arguments once per query execution.<br><br>The bad news about this is that your query might still fail at run time if you try to open it in Visual Basic as a Recordset.<br><br>Best<br><br>Harry Rich
 
The only way I've ever been able to access a variable value in a query is by using a function that returns it, or by referring to a value on an open form (Forms!FormName!ControlName). If there is a way to call it directly from storage I'd be interested in hearing about it.
 
Thanks all.&nbsp;&nbsp;Some answers:<br><br>HIM:&nbsp;&nbsp;I'm trying to select a subset of records based on two values input on a form and stored in the PUBLIC variables.&nbsp;&nbsp;The criteria I've been trying to get to work is:<br><br>&gt;=StartValue AND &lt;=EndValue<br><br>where StartValue and EndValue are the PUBLIC variables.<br><br>harryrich:&nbsp;&nbsp;Do you have some sample code you could provide to the group?&nbsp;&nbsp;It sounds as if elizabeth and perto (as well as me!) would be VERY interested in making this type of thing work.<br><br>Again, thanks to everyone - these forums are WONDERFUL!!!<br><br>Best,<br><br>Tom
 
BTW, I guess actually I have done this one other way, and that's to capture the values in a table, then retrieve them directly in the query.
 
Elizabeth:<br><br>A table!&nbsp;&nbsp;Why didn't I think of that???&nbsp;&nbsp;&lt;sigh&gt;&nbsp;&nbsp;Life just isn't supposed to be this complicated - I'm convinced of that.<br><br>Anyway, I can do that - we're only talking one set of values at a time and I can clear out the table after I print the report.<br><br>THANKS!!!!!<br><br>Tom
 
Glad that helped. It's sometimes useful to leave the values in there in case you want to let the user see what the parms were the last time someone ran that report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top