tags:

views:

82

answers:

2

sir, it like searching function

i need to search the table which has data stored in ms access table. i have create a text box for the contract no,username and date and need to search the table according to contract no or username or date.

for that i need a coding with solve the problem in single sql command. i have try it with where help is a table,search-test is form.

when the help(table).cont_no(field) is equal to search-test(form name).cont_no(text box field)

SELECT 
  * 
FROM 
  Help 
WHERE 
  (((Help.cont_no)=[Forms]![search-test]![cont_no])) 
  OR (((Help.username)=[Forms]![search-test]![username]) 
  or ((Help.date)=[Forms]![search-test]![cbo_date]));

hope you will understand my view

A: 

Hi,

Assuming that contract no and user name are Text type fields you need to enclose the strings in apostrophe's to enclose text/strings

something like

DoCmd.RunSQL "SELECT Help.cont_no, Help.Req_no, Help.Br_name, Help.br_code, Help.Remarks, Help.Status, Help.username, Help.case, Help.date FROM Help

WHERE (((Help.cont_no)=" & "'" & [Forms]![search-test]![cont_no])) & "'" & " OR ....

Thanks

express-way
Not in the query design window, you don't. This is only necessary if you are building SQL in VBA.
Remou
Er, DoCmd.RunSQL is not valid for SELECT statements.
David-W-Fenton
A: 

Hello, I believe you have duplicated your question here: http://stackoverflow.com/questions/3418179/sql-query-based-upon-some-criteria/3480475#3480475

If not, please elaborate a bit more on the new problem you're having. Thanks

EDIT: Actually, you have triplicated your question http://stackoverflow.com/questions/3421608/sql-query-based-on-criteria

EDIT: If you add comments or edit your original question it will be automatically bumped. There is no reason to deliberately post your questions multiple times... not only because of clutter but also because people trying to help you will not be able to see the progress of your question so far

Matthew PK