All indexes or just one

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All

I use a simple query to pull all the product indexes from a table:
SELECT DISTINCT tblIndex.ProductID
FROM tblIndex;

How do I get the query to use a specific index when the user chooses a
product or pull all the distinct indexes when no selection is made?

Appreciate the help.
Dave
 
If the Index is specified in a form, try

SELECT DISTINCT tblIndex.ProductID
FROM tblIndex
Where ProductID = Forms![FormName]![TextBoxName] Or
Forms![FormName]![TextBoxName] Is Null

Or, when the user is prompt to select a product

SELECT DISTINCT tblIndex.ProductID
FROM tblIndex
Where ProductID = [Please select a product] Or [Please select a product] Is
Null
 
Tried various forms in the sql statement like IIF([textBox] Is Null ...)
which didn't work. Put your solution in the query box and it worked like a
charm. Thank you for your help.

Ofer Cohen said:
If the Index is specified in a form, try

SELECT DISTINCT tblIndex.ProductID
FROM tblIndex
Where ProductID = Forms![FormName]![TextBoxName] Or
Forms![FormName]![TextBoxName] Is Null

Or, when the user is prompt to select a product

SELECT DISTINCT tblIndex.ProductID
FROM tblIndex
Where ProductID = [Please select a product] Or [Please select a product] Is
Null


--
Good Luck
BS"D


Dave said:
Hello All

I use a simple query to pull all the product indexes from a table:
SELECT DISTINCT tblIndex.ProductID
FROM tblIndex;

How do I get the query to use a specific index when the user chooses a
product or pull all the distinct indexes when no selection is made?

Appreciate the help.
Dave
 
Back
Top