A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL Select Query Prompting for NonExistent Parameter



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2010, 02:25 AM posted to microsoft.public.access.queries
David[_62_]
external usenet poster
 
Posts: 13
Default SQL Select Query Prompting for NonExistent Parameter

I'm using Access 97.

I've entered the following SQL Query into the Query Tab.

===================

SELECT * FROM tblVehicles WHERE fldVehicleTag = ABC123;

====================

When I double click the Query to execute:

Instead of returning the recordset Access prompts me for
a Parameter. When I enter the tag # -- ABC123
it returns the correct record.

Why am I being prompted for a Parameter and how do I stop it?

Thanks
David


  #2  
Old March 18th, 2010, 02:43 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default SQL Select Query Prompting for NonExistent Parameter

On Wed, 17 Mar 2010 22:25:13 -0400, "David" wrote:

I'm using Access 97.

I've entered the following SQL Query into the Query Tab.

===================

SELECT * FROM tblVehicles WHERE fldVehicleTag = ABC123;

====================

When I double click the Query to execute:

Instead of returning the recordset Access prompts me for
a Parameter. When I enter the tag # -- ABC123
it returns the correct record.

Why am I being prompted for a Parameter and how do I stop it?

Thanks
David


You need quotemarks around the text criterion:


SELECT * FROM tblVehicles WHERE fldVehicleTag = 'ABC123';

Criteria on Text fields must be delimited by ' or "; Date/Time fields must be
delimited by # (for date literals); Number or Currency fields use no
delimiter.


--

John W. Vinson [MVP]
  #3  
Old March 18th, 2010, 03:07 AM posted to microsoft.public.access.queries
David[_62_]
external usenet poster
 
Posts: 13
Default SQL Select Query Prompting for NonExistent Parameter

Thanks Mr. Vinson -- Worked GREAT!

One other followup. Instead of SQL, I tried Access's
Query Designer (hope I have this name correct).
I entered the test Tag Number under Criteria.

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


"John W. Vinson" wrote in message
...
On Wed, 17 Mar 2010 22:25:13 -0400, "David" wrote:

I'm using Access 97.

I've entered the following SQL Query into the Query Tab.

===================

SELECT * FROM tblVehicles WHERE fldVehicleTag = ABC123;

====================

When I double click the Query to execute:

Instead of returning the recordset Access prompts me for
a Parameter. When I enter the tag # -- ABC123
it returns the correct record.

Why am I being prompted for a Parameter and how do I stop it?

Thanks
David


You need quotemarks around the text criterion:


SELECT * FROM tblVehicles WHERE fldVehicleTag = 'ABC123';

Criteria on Text fields must be delimited by ' or "; Date/Time fields must
be
delimited by # (for date literals); Number or Currency fields use no
delimiter.


--

John W. Vinson [MVP]



  #4  
Old March 18th, 2010, 03:24 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default SQL Select Query Prompting for NonExistent Parameter

On Wed, 17 Mar 2010 23:07:26 -0400, "David" wrote:

Thanks Mr. Vinson -- Worked GREAT!

One other followup. Instead of SQL, I tried Access's
Query Designer (hope I have this name correct).
I entered the test Tag Number under Criteria.


The query grid is simply a tool to construct SQL. The SQL is a) the real
query, and b) much easier to post and discuss on newsgroups.

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


The order of columns in the query grid should match the order of fieldnames in
the SQL SELECT clause, and should also control the order in which the fields
appear in the query grid. I'm not aware of any automagical reordering!
--

John W. Vinson [MVP]
  #5  
Old March 18th, 2010, 04:10 AM posted to microsoft.public.access.queries
David[_62_]
external usenet poster
 
Posts: 13
Default SQL Select Query Prompting for NonExistent Parameter

Thank you for your time.

Have a nice evening.

David

"John W. Vinson" wrote in message
...
On Wed, 17 Mar 2010 23:07:26 -0400, "David" wrote:

Thanks Mr. Vinson -- Worked GREAT!

One other followup. Instead of SQL, I tried Access's
Query Designer (hope I have this name correct).
I entered the test Tag Number under Criteria.


The query grid is simply a tool to construct SQL. The SQL is a) the real
query, and b) much easier to post and discuss on newsgroups.

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


The order of columns in the query grid should match the order of
fieldnames in
the SQL SELECT clause, and should also control the order in which the
fields
appear in the query grid. I'm not aware of any automagical reordering!
--

John W. Vinson [MVP]



  #6  
Old March 18th, 2010, 05:10 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default SQL Select Query Prompting for NonExistent Parameter

On Wed, 17 Mar 2010 23:07:26 -0400, "David" wrote:

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


My guess is that you got this result because you included both the
fldVehicleTag explicitly (for the criterion), and the * operator which returns
all fields. It probably put the field you specified first and then all the
other fields (or it may have included fldVehicleTag twice, aliasing one of
them as Expr1).

You can select all of the fields individually or as a group - select them all
from the field list and drag them to the grid, and leave off the *. You can
then arrange the fields in any order you like.
--

John W. Vinson [MVP]
  #7  
Old March 18th, 2010, 02:23 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default SQL Select Query Prompting for NonExistent Parameter

Ah, but you can rearrange columns in datasheet view and if you save the
changes the Access will remember the changes to the datasheet view.

That doesn't explain the order the poster sees if he just opened a new query
and used the "query designer"

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

John W. Vinson wrote:
On Wed, 17 Mar 2010 23:07:26 -0400, "David" wrote:

Thanks Mr. Vinson -- Worked GREAT!

One other followup. Instead of SQL, I tried Access's
Query Designer (hope I have this name correct).
I entered the test Tag Number under Criteria.


The query grid is simply a tool to construct SQL. The SQL is a) the real
query, and b) much easier to post and discuss on newsgroups.

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


The order of columns in the query grid should match the order of fieldnames in
the SQL SELECT clause, and should also control the order in which the fields
appear in the query grid. I'm not aware of any automagical reordering!

  #8  
Old March 18th, 2010, 02:25 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default SQL Select Query Prompting for NonExistent Parameter

John,

Good one. I'll have to keep this in mind when I am answering questions.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

John W. Vinson wrote:
On Wed, 17 Mar 2010 23:07:26 -0400, "David" wrote:

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


My guess is that you got this result because you included both the
fldVehicleTag explicitly (for the criterion), and the * operator which returns
all fields. It probably put the field you specified first and then all the
other fields (or it may have included fldVehicleTag twice, aliasing one of
them as Expr1).

You can select all of the fields individually or as a group - select them all
from the field list and drag them to the grid, and leave off the *. You can
then arrange the fields in any order you like.

  #9  
Old March 20th, 2010, 01:30 PM posted to microsoft.public.access.queries
David[_62_]
external usenet poster
 
Posts: 13
Default SQL Select Query Prompting for NonExistent Parameter

Thanks Mr. Vinson and Mr. Spencer.

Problem resolved.

Appreciate your efforts on my behalf.

Normally use SQL and Access as backend to VB, so not comfortable with "inter
workings" of Access interface. Need to allocate some time in that area.

Have a nice day.

David

"John Spencer" wrote in message
...
John,

Good one. I'll have to keep this in mind when I am answering questions.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

John W. Vinson wrote:
On Wed, 17 Mar 2010 23:07:26 -0400, "David"
wrote:

Of interest, is that the Query returned the correct record
but with the fldVehicleTag column in the first position.
Anyone to replicate this in SQL or is this a field "reorder" function
that is part of Access?


My guess is that you got this result because you included both the
fldVehicleTag explicitly (for the criterion), and the * operator which
returns
all fields. It probably put the field you specified first and then all
the
other fields (or it may have included fldVehicleTag twice, aliasing one
of
them as Expr1).

You can select all of the fields individually or as a group - select them
all
from the field list and drag them to the grid, and leave off the *. You
can
then arrange the fields in any order you like.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.