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!

Troubleshooting code not working. Can you go thru what this code is 2

Status
Not open for further replies.

mvital

Technical User
Jul 2, 2003
128
0
0
US
doing? I have been troubleshooting this code because it WAS working last Friday and no longer is. I am not sure why. basically I have a text field on an access form called "txtsourcekeyword" the user can search for a particular MATERIAL_ID (CDW-01;text field)if he/she knows it or enter wildcard info CD*. The list box 'FormIndex' should then be filtered to show all the records with CD* and it is not doing that.

Any ideas? If I understand the code better maybe I can troubleshoot it better.
This is the code I have behind the command button to find the material_id.

Private Sub cmdViewSources_Click()
wherestring = vbNullString
If IsNull(txtSourceKeyword) Then

FormIndex.RowSource = "SELECT tbl_material_description.MATERIAL_ID, tbl_material_description.BUILDING_ID FROM tbl_material_description ORDER BY tbl_material_description.MATERIAL_ID;"

Else
strWildcard = txtSourceKeyword

wherestring = "WHERE(((tbl_material_description.MATERIAL_ID) like ""*" & strWildcard & "*""))"

FormIndex.RowSource = "SELECT tbl_material_description.MATERIAL_ID, tbl_material_description.BUILDING_ID FROM tbl_material_description ORDER BY tbl_material_description.MATERIAL_ID;"
End If

End Sub

thanks in advance!
 
Hint: why populating wherestring if you don't use it ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm sorry I don't understand.

I thought it was populated by this piece:

wherestring = "WHERE(((tbl_material_description.MATERIAL_ID) like ""*" & strWildcard & "*""))"
 
Yes, it is populated but never used ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
So is why it is not working? I am sorry new coder here, but learning a lot thanks to Tek-Tips!

 
Code:
FormIndex.RowSource = "SELECT tbl_material_description.MATERIAL_ID, tbl_material_description.BUILDING_ID FROM tbl_material_description [COLOR=red]" & wherestring[/color] & " ORDER BY tbl_material_description.MATERIAL_ID"




 
Thanks SO much 'JoeAtWork'!!!

It works great!

Have a good one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top