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

Search Engine in Access

Status
Not open for further replies.

Kindi

Programmer
Jan 31, 2001
54
GB
I need a form, where i can add about 5 items from which a user can select serach criteria from e.g drop down boxes or add data e.g date and search for records on the criteria entered. I am not sure how to create the search, i have tried the filters, but not sure how to use them, or would it be better to have a command button with some sort of SQL statement, that opens a form with all the serached records, based on criteria entered?

Please help!
 
Hi!

You can create criteria clause for records filter of form.

dim strLinkCriteria as string

if not isnull(Item1) then
strLinkCriteria = "Field1=" & Item1
'Numeric value
end if

if not isnull(Item2) then
if strLinkCriteria <>&quot;&quot; then
strLinkCriteria = strLinkCriteria & &quot; And &quot;
'&quot; Or &quot;
end if
strLinkCriteria = strLinkCriteria & &quot;Field2='&quot; & Item2 & &quot;'&quot;
'Text value
end if

if not isnull(Item3) then
if strLinkCriteria <>&quot;&quot; then
strLinkCriteria = strLinkCriteria & &quot; And &quot;
'&quot; Or &quot;
end if
strLinkCriteria = strLinkCriteria & &quot;Field3=#&quot; & Item3 & &quot;#&quot;
'Date value
end if

......
......
etc.

DoCmd.OpenForm &quot;MyForm&quot;, , , strLinkCriteria


Aivars
 
Hi
Thanks this is exactly the type of thing i want to do, but should i put all this code behind a command button?

Thanks
Kindi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top