Rebecca
Wed Aug 20 11:41:33 CDT 2003
What you need to do is create the SQL query on the fly, and I'll warn you
that it's not difficult, but tedious. Something like
dim Criteria as String
If len(<firstControl.Text>) > 0 then
Criteria = "<fieldName> = " & <firstControl>.Text
End If
If len(<secondControl.Text>) > 0 then
End IF
If len(Criteria) > 0 then
Criteria &= "and <fieldname> = " & <secondControl>.Text
Else
Criteria = '<fieldname> = " & <secondControl>.Text
End If
End If
... repeat for each control
dim qryString as String = "<SELECT whatever...>"
If len(Criteria) > 0 then
qryString &= "WHERE " & criteria"
EndIf
...execute the query and process the results
Rather than a long bit of repetitive text, you can loop through the Controls
collection of the form, but frankly, because of the hassle of storing the
fieldname somewhere, and sorting out the fields that don't apply (like the
Search button), I find it easier to just type it out. But then, I type fast
<g>.
HTH
--
Rebecca Riordan, MVP
Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step
http://www.microsoft.com/mspress
Blessed are they who can laugh at themselves,
for they shall never cease to be amused...
"Wired" <someone@somewhere.com> wrote in message
news:5hu2kv4u16dudvrm2skoq8h51aji44crco@4ax.com...
> Excuse me for asking a "newbie" question...but, I'm new to using
> vb.net. I have a database I have created using Access tables.
> I would like to create a Search box similar to the built in one in
> access that allows you to click on a field and type in the search
> string and it brings up the related record. Any ideas how to do this
> or maybe where I can find more information on how to do it?
> Thanks in advance!!