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

SQL Query by form

Status
Not open for further replies.

heehaw

Programmer
Mar 2, 2002
11
0
0
US
Want to do a QBF (query by form) for data in a SQL Server. Using Access (project) as the frontend and SQL7 as the db. In Old Access I used to write

Like Forms!SearchForm!SearchField & "*" Or Forms!SearchForm!SearchField Is Null

This was written in several query fields and using an unbound form, I could query a table with one or several fields at once. I haven't really tried this much, but this doesn't seem to fire in SQL and it looks like my simple QBF is going to get really complicated. Is that true?

Does anyone out there have a really good QBF technique they want to share for Access frontend and a SQL backend?

Just looking for ideas before I start slapping the monitor and cursing outloud when I'm alone.

HeeHAw
 
Here are the 2 that I have used, and I have nother one, but I am doing an OS reload, and cannot access it at the moment.
This is done in VBA, with a Textbox and a Button event OnClick(). It has benn a while since I have used it, and again, do not have access to the production version of this. I will send more info if needed.


~Search Query w/o wildcard~

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;<Form>&quot;

stLinkCriteria = &quot;[<Field>]=&quot; & Me![<TextBoxName>]
DoCmd.close
DoCmd.OpenForm stDocName, , , stLinkCriteria

~Search Query w/ Wildcard~

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;<Form>&quot;

stLinkCriteria = &quot;[<Field>]LIKE&quot; & &quot;'&quot; & Me![<TextBoxName>] & &quot;%'&quot;
DoCmd.close
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Thanks. That was kind of what I was looking for and enough of a clue to write it myself. I did and it worked. Now I will expand on that.

Heehaw
 
If you were able to exploit, and make that code more functional, I would love to see the code. If you do not mind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top