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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query help please?

Status
Not open for further replies.

rukk

Programmer
Dec 29, 2003
38
US
I have wriiten a parameter query like below

SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #])=[Enter Record Number]));

This will populate a message saying "Enter Record Number" and displays that result. But this one only do this for 1 record.

But my client needs records more than one, how to write a query to do that?
 
SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #]) BETWEEN [Enter Starting Record Number] AND [Enter Ending Record Number]));


Leslie
 
Thank you so much for your quick response.
In that case i can specify records if i want from 10 to 100.
But in this case i need to get perticular records like 11,19,65,54 etc. How to do that?
 
SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #]) In [Enter All Record Numbers separated by commas]));

Leslie
 
I have tried
SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #]) In [Enter All Record Numbers separated by commas]));

still not working
also i tried
SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #]) In [Enter All Record Numbers separated by commas], [enter no]));
then it is asking twice and giving result with two number that i have specified
 
forgot the parens, try this instead:

SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (((tblCycleFeedBackData.[Record #]) In ([Enter All Record Numbers separated by commas])));

Leslie
 
Not Parenthesis problem, i have corrected that when i got syntax error, its just giving me result for one record, if give records with comma sepearation its not giving result
 
Try something like this:

SELECT tblCycleFeedBackData.*
FROM tblCycleFeedBackData
WHERE (tblCycleFeedBackData.[Record #])=[Record Number 1] OR tblCycleFeedBackData.[Record #])=[Record Number 2] OR tblCycleFeedBackData.[Record #])=[Record Number 3]);

-VJ
 
That works for only up to 3 records, but in this case if the user want to get 5 records, it varies, it won't be same number of records all the time. sometimes user may need 10 records, if i write a query for 3 or 5 records then its not going to work for 10 records. This query is a record source for the report.
 
Then I would create my own input form that has a text box and a command button. Have the users put the criteria in the text box and when the command button is pressed, create the query there.

Is [Record #] a text field or a number field?

leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top