Parameter Query help - Not passing parameter?

M

Marc T

Hi all,

probably a very basic question, but I am having a bit of a problem setting
up a parameter query.
I have access connecting via ODBC to an external database and returning two
tables. What I want to do is limit these tables by the project id field. Now
I can get this to work fine if I state the project id in the SQL as below:

SELECT .......
........
WHERE (((extdb.PROJECT_ID)="123456"));

but as soon as I try to have this passed as a parameter (as below) it
doesn't return anything.

PARAMETERS [Project No] Text ( 255 );
SELECT ......
.........
WHERE (((extdb.PROJECT_ID)="Project No"));


does anyone know where I'm going wrong?

Also, I'll probably need to be calling this query from Excel, is there any
standard way to pass the parameter using excel VBA?

Thanks and regards,
Marc
 
M

Marc T

Thanks for the help Jerry.

boy do I feel like a chump for missing the brackets!

Would you know how to pass the parameter value from an Excel worksheet by
any chance? I've got the query being run via a small bit of VBA code within
Excel as it stands.

Marc

Jerry Whittle said:
=[Project No]

The parameter must be in [] square brackets and not quotes.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Marc T said:
Hi all,

probably a very basic question, but I am having a bit of a problem setting
up a parameter query.
I have access connecting via ODBC to an external database and returning two
tables. What I want to do is limit these tables by the project id field. Now
I can get this to work fine if I state the project id in the SQL as below:

SELECT .......
.......
WHERE (((extdb.PROJECT_ID)="123456"));

but as soon as I try to have this passed as a parameter (as below) it
doesn't return anything.

PARAMETERS [Project No] Text ( 255 );
SELECT ......
........
WHERE (((extdb.PROJECT_ID)="Project No"));


does anyone know where I'm going wrong?

Also, I'll probably need to be calling this query from Excel, is there any
standard way to pass the parameter using excel VBA?

Thanks and regards,
Marc
 
J

Jerry Whittle

Not a clue on the Excel question. Maybe they could help over in the Excel
forums.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Marc T said:
Thanks for the help Jerry.

boy do I feel like a chump for missing the brackets!

Would you know how to pass the parameter value from an Excel worksheet by
any chance? I've got the query being run via a small bit of VBA code within
Excel as it stands.

Marc

Jerry Whittle said:
=[Project No]

The parameter must be in [] square brackets and not quotes.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Marc T said:
Hi all,

probably a very basic question, but I am having a bit of a problem setting
up a parameter query.
I have access connecting via ODBC to an external database and returning two
tables. What I want to do is limit these tables by the project id field. Now
I can get this to work fine if I state the project id in the SQL as below:

SELECT .......
.......
WHERE (((extdb.PROJECT_ID)="123456"));

but as soon as I try to have this passed as a parameter (as below) it
doesn't return anything.

PARAMETERS [Project No] Text ( 255 );
SELECT ......
........
WHERE (((extdb.PROJECT_ID)="Project No"));


does anyone know where I'm going wrong?

Also, I'll probably need to be calling this query from Excel, is there any
standard way to pass the parameter using excel VBA?

Thanks and regards,
Marc
 

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