why this code not working ???

siamandm
BronzeLounger
Posts: 1221
Joined: 01 May 2016, 09:58

why this code not working ???

Post by siamandm »

hello all

i have this code working fine on a form, i do the same exact thing now its not working and not giving any errors?!!!

Code: Select all

rivate Sub txtSearch_Change()
On Error GoTo Err_txtProperty_Change
Dim sql As String

sql = "Select Products.[Product Code], Products.[Product Name] from products" _
& " Where [Product Code] like '*" & Me.txtSearch .text& "*'"

Me.CustomerList.Form.RecordSource = sql
Me.CustomerList.Form.Requery


Me.lstCustomer.RowSource = sql
Me.lstCustomer.Requery
Err_txtProperty_Change:

End Sub

User avatar
HansV
Administrator
Posts: 78444
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: why this code not working ???

Post by HansV »

Insert an apostrophe ' before the line

On Error GoTo Err_txtProperty_Change

to make it a comment. Do you now get an error message?
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1221
Joined: 01 May 2016, 09:58

Re: why this code not working ???

Post by siamandm »

i even removed that line still not working:(

User avatar
HansV
Administrator
Posts: 78444
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: why this code not working ???

Post by HansV »

No error message?
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1221
Joined: 01 May 2016, 09:58

Re: why this code not working ???

Post by siamandm »

no !! its only not filtering my data i get blank list box!
but same code works in my backup database!!! i was expecting database damage but i did repair compact ... no luck

User avatar
HansV
Administrator
Posts: 78444
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: why this code not working ???

Post by HansV »

Above the line

Code: Select all

Me.CustomerList.Form.RecordSource = sql
insert

Code: Select all

Debug.Print sql
After the code has run, look at the Immediate window in the Visual Basic Editor. What do you see there?
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1221
Joined: 01 May 2016, 09:58

Re: why this code not working ???

Post by siamandm »

thank you very very much , through this little code i learned a big info,
i found the issue is from the space !!!! which i never expected that this will make issues , have a look on the screenshot after adding a space after double quotation the problem solved!
Capture.PNG
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78444
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: why this code not working ???

Post by HansV »

That's great!
Best wishes,
Hans