473,796 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Default query parameter values

Hi...

I have a query which I'm accessing through PHP as a stored procedure.
However, I need to be able not to pass a couple of parameters in certain
situations. When I do this, I get an error:

[Microsoft][ODBC Microsoft Access Driver] Parameter [@str_year] has no
default value.

But it works fine in Access when I run the query from there and just hit
enter on the relevant parameter dialog. Is there a way of setting a default
value for a query parameter? I can't find out anything about it...

TIA.
Plankmeister.
Nov 12 '05 #1
2 5845
AFAIK Access has no way to set/store default parameter values.
When you "just hit enter", you are entering the empty string which was
displayed in the parameter dialog.
You might try setting that parameter to a blank string programatically .

HTH
- Turtle

"The Plankmeister" <pl************ ******@hotmail. com> wrote in message
news:3f******** *************** @dread12.news.t ele.dk...
Hi...

I have a query which I'm accessing through PHP as a stored procedure.
However, I need to be able not to pass a couple of parameters in certain
situations. When I do this, I get an error:

[Microsoft][ODBC Microsoft Access Driver] Parameter [@str_year] has no
default value.

But it works fine in Access when I run the query from there and just hit
enter on the relevant parameter dialog. Is there a way of setting a default value for a query parameter? I can't find out anything about it...

TIA.
Plankmeister.

Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm assuming you mean that you have a stored procedure (SP) in MSDE or
MS SQL Server, not a SP in PHP. Here is how to define a default
parameter value in a MS SQL Server SP:

CREATE PROCEDURE usp_thisSP
@first_paramete r VARCHAR(32) = 'business'
@second_paramet er MONEY = 200.00
AS
.....

I believe you can use a method described in KB103181 (my modification
for MS SQL Server - untested - don't know if setting a variable to a
NULL will work):

CREATE PROCEDURE usp_AnotherExam ple
@ShipCountry VARCHAR(4) = NULL
AS
.....

WHERE @ShipCountry IS NULL
OR (Orders.ShipCou ntry=@ShipCount ry AND @ShipCountry IS NOT NULL )

HTH,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9TzzIechKq OuFEgEQL/ggCg9aXgPgKZWKd IsRNnsuOM5lisb0 cAoPyh
PK4Y6I9/36a+Uoq2FlH3KUo M
=8YF3
-----END PGP SIGNATURE-----
The Plankmeister wrote:
Hi...

I have a query which I'm accessing through PHP as a stored procedure.
However, I need to be able not to pass a couple of parameters in certain
situations. When I do this, I get an error:

[Microsoft][ODBC Microsoft Access Driver] Parameter [@str_year] has no
default value.

But it works fine in Access when I run the query from there and just hit
enter on the relevant parameter dialog. Is there a way of setting a default
value for a query parameter? I can't find out anything about it...

TIA.
Plankmeister.


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5422
by: jason | last post by:
I am picking up an error message on a straightforward INSERT - do I need an optimistic-type to get this working....here is is the error: Microsoft JET Database Engine error '80004005' Operation must use an updateable query. /catamaranco/accounts/email_inc.asp, line 264 Set cnn = CreateObject("ADODB.Connection") strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../database/acc.mdb") '//This one is for Access...
6
3789
by: Jason | last post by:
I have a function which performs a query and returns a table. The one parameter that can get passed in is a date which defaults to NULL. There is an IF statement in the function that will set the paramter to an actual date if null. If I call the function while passing in a date the function comes back a second or 2 later. But if I pass in DEFAULT to the function, the same query takes 8 minutes. See code below and sample call below. ...
3
7551
by: MX1 | last post by:
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and the other is criteria for a Yes or No field. I'll focus on the Yes/No field for simplicity. If I run the query with the criteria hard coded as either "YES" or "NO", it works. In the values of the combo box in my form, I have it set as...
2
2687
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the keyed values description. I need a parameter query to return a range of these values. The parameter input won't accept the 'text' version. You can do it with 'Find' because you can select 'as formatted'. But I need a range. Please, any...
3
23177
by: Ryan Hubbard | last post by:
I would like to run a query from VBA. The query will be one with parameters. Is there a way to run the query and have Access prompt for the values like it does if I where to execute it through the database window?
4
5731
by: Andy Davis | last post by:
I have developed a number of reports that are based on parameter queries where the user enters criteria such as a date range and a sales rep say. I want to be able to show a graphical picture in the form of a bar chart based on the data within the report. Can I do this as when I have tried to insert a chart on the report it displays an error saying that it doeds not recognise the parameter criteria. Am I right to assume that maybe a chart...
21
5773
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code would go something like this: dim qry as dao.querydef set qry = currentdb.querydefs("myquery") qry.parameters("Par1") = "blah"
20
5246
by: exipnakias | last post by:
Hello Guys. In a form I created a listbox which looks up the values of a table. I want: 1) ..to create a query where a parameter will be needed in order to be loaded. But I do not want to write the parameter, I want to select a row from the listbox and after clicking in a button, the query to automatically take the current value of listbox as the needed parameter and then to load the query. (The Inputbox for "Enter Parameter" will...
7
5524
by: Kelii | last post by:
Well, I've been searching around the groups for an answer to this one, and none of the suggestions seems to be working for me. I'm almost positive that this is a simple fix, but for the life of me I can't figure out what I'm doing wrong. I have a form that uses a query as its recordsource; I'll call the query qryParent. qryParent is based on 2 nested queries; which is to say qryParent selects from qryChild2 and qryChild2 selects from...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.