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

Criteria with SQL LIKE Problem. 2

Status
Not open for further replies.

Talonjpc

Programmer
Jul 29, 2002
21
0
0
US
Talonjpc (Visitor) Jul 29, 2002
I know the SQL LIKE command allows someone to search for a value that matches part of the criteria. However, how do you use the LIKE command with User entered criteria. I want the user to enter a server's network name, so in the criteria I put Like [Network Name] However the []means something different with the LIKE command, I know that much, so Database will not prompt the user for the Network Name
So my question is, how can I use this command with user based criteria.

Thanks,
Vinay

 
The criteria row should look like this:

Like [Enter Network Name:] & "*"

Let me know if you need more. Bob Scriver
 
Thanks

One more question. If I wanted to avoid applying a filter and instead used the wherecondition parameter of the DoCmd.OpenReport Command, how would I write that part

DoCmd.OpenReport "CompleteComputerReport",AcPreview,,?????

 
Try this:

Dim vWhereClause as string
vWhereClause = "WHERE (((tblYourTable.[NetWorkName]) Like [Enter Network Name:] & '*'));"

DoCmd.OpenReport "CompleteComputerReport",AcPreview,,vWhereClause

You will have to change the table name and field name(Green Entries0 in the WHERE statement string to those specific to your database. Let me know if this works for you. Bob Scriver
 
I had to modify the SQL statement a bit to get the code to run, but it did and worked. Here is my final code

Dim vWhereClause As String
vWhereClause = "(([Computer Basic].[Network Name]) Like [Forms]![CompleteComputerEntry]![Network Name] & '*')"

Dim stDocName As String
stDocName = "Computer Information Report"
DoCmd.OpenReport stDocName, acPreview, , vWhereClause
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top