expression for "All fields on form"

J

jason

Hello all. very easy question. take a look at my code:

Else
stDocName = "SWDATA"
stLinkCriteria = "([SITE] Like ""*" & Me.Text0 & _
"*"") OR ([NUM] Like ""*" & Me.Text0 & _
"*"") OR ([SYSTEM] Like ""*" & Me.Text0 & _
"*"") OR ([NAME] Like ""*" & Me.Text0 & _
"*"") OR ([VER] Like ""*" & Me.Text0 & _
"*"") OR ([QUANTITY] Like ""*" & Me.Text0 & _
"*"") OR ([SN] Like ""*" & Me.Text0 & _
"*"") OR ([MGR] Like ""*" & Me.Text0 & _
"*"") OR ([DEPT] Like ""*" & Me.Text0 & _
"*"") OR ([STN] Like ""*" & Me.Text0 & _
"*"") OR ([DATE REC'D] Like ""*" & Me.Text0 & _
"*"") OR ([USER] Like ""*" & Me.Text0 & _
"*"") OR ([UPDATE/NEW] Like ""*" & Me.Text0 & _
"*"") OR ([STATUS] Like ""*" & Me.Text0 & _
"*"") OR ([PURCHASE #] Like ""*" & Me.Text0 & _
"*"") OR ([VENDOR] Like ""*" & Me.Text0 & _
"*"") OR ([SERVER] Like ""*" & Me.Text0 & _
"*"") OR ([COMMENTS] Like ""*" & Me.Text0 & "*"")"
DoCmd.OpenForm stDocName, , , stLinkCriteria

instead of having to type every field on my form like i
did, is there a expression (code) to say "all fields"
instead?
 
J

John Vinson

instead of having to type every field on my form like i
did, is there a expression (code) to say "all fields"
instead?

No; you could write VBA code to loop through the Controls collection
of the form, and build up this SQL string.

I *REALLY* have to question the validity of doing this operation AT
ALL, however! Why do you want to search totally disparate and
incompatible fields (QUANTITY, DATE REC'D, VENDOR, etc. etc.) with THE
SAME CRITERION? Note that the search as written *will fail* for
searching date fields (which are not text strings), and - if the user
enters a single digit - will return innumerable false hits. In
addition, it will be VERY slow if your table is of any size, since it
will do a full table scan and will be unable to use any indexes.

WHY? What's the point, from the user perspective?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top