my code for search is
rec.Open "select * from Body_Markings_new where Part Number like '%" & txtsearch.Text & "%' ", conn, adOpenDynamic, adLockOptimistic

after compiling this code getting an error saying syntax error (missing operator) in query expression 'part number like' %1%"

please help me I not able to fix this.

Recommended Answers

All 3 Replies


rec.Open "select * from Body_Markings_new where [Part Number] like '%" & txtsearch.Text & "%' ", conn, adOpenDynamic, adLockOptimistic

It's my own preference, but I always avoid putting spaces in field names. It always leads to problems like this.

Hi Jim,
It works, thanks a lot for your help.
Ofcourse I tried without spacce also, it was not worked. After placeing square brackets it works.

Hi Jim,
I have one more issue..

tht after searching part number in datagrid, it will display the searched item in same datagrid. After tht i want to refresh the datagrid with completely.

can you please help me on this.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.