invalid use of property

Dim search As String
        search = Trim(txtSearch.Text)
    Select Case cmbSearch
        Case "By: Customer Name": Call DataGrid("select * from list1 where CustomerName like '" & search & "%'")
        Case "By: Date": Call DataGrid("select * from list1 where Date like '" & search & "%'")
        Case "By: Event": Call DataGrid("select * from list1 where Event like '" & search & "%'")
        Case "By: Comment": Call DataGrid("select * from list1 where Comment like '" & search & "%'")
    End Select

DATAGRID
ADODC
MYSQL
database: database1
table: list1

Suggestion:--
1. Instead of using Case cmbSearch
Case "By: Customer Name":

take the value from a combobox instead (use the index in CASE not the text).

2. Don't use like operator on a Date field, you will get unexpected result.

Q. What is that DataGrid in your code, is that simply a control or a method name ?

Suggestion:--
1. Instead of using Case cmbSearch
Case "By: Customer Name":

take the value from a combobox instead (use the index in CASE not the text).

Select Case cmbSearch.ListIndex

Case Is = 0
'Code here
Case Is = 1
'Code Here
End Select

2. Don't use like operator on a Date field, you will get unexpected result.

Call DataGrid("select * from list1 WHERE Date = DateValue('" & search & "'")

Q. What is that DataGrid in your code, is that simply a control or a method name ?

It is a sub calling accordingly...

Cry loud.

No one is going to care for you till you show some effort, and that has already been communicated to you.

Edited 5 Years Ago by debasisdas: n/a

i dont have any clue where to start i am done searching it's not working for me..tsk

I had a look at the attached file. The user was using a Listview control and NOT a datagrid, that is why your code did not work as was the intention. Change your datagrid to a listview if you want it to work the same as the attached code.

error :(

If Adodc.Recordset.RecordCount > 0 Then Adodc.Recordset.MoveFirst
Adodc.RecordSource = "details where upper(CustomerName) like '%" & UCase(Trim(txtSearch.Text)) & "%'"
Adodc.Refresh
Attachments Untitled-1.jpg 19.77 KB
Adodc.RecordSource = "details where upper(CustomerName) like '" & UCase(Trim(txtSearch.Text)) & "%'"

Remove the first "%" sign.

it's still the same
when i click debug this one will get yellow

Adodc.Refresh

did u figure out my module?

As far as the module goes, I've tested it and it was working fine on my side. Post all the code in your module, I think you are calling the same connection twice, hence the error.

Your problem above, adodc is a reserved name, you can not name a function with that name, unless it is a data control and not code...

I will have to see a screen capture of your design form and the code. I still say that Adodc is a data control...

If Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.MoveFirst
Adodc1.RecordSource = "details where upper(CustomerName) like '" & UCase(Trim(txtSearch.Text)) & "%'"
Adodc1.Refresh
conn.Close
Attachments Untitled-1.jpg 2.11 KB

See, I told you that adodc is a data control, hence the error. You need to search your form for it and make sure that the connection is set properly, then set the recordsource -

Adodc.RecordSource = "SELECT * FROM details WHERE CustomerName like '" & UCase(Trim(txtSearch.Text)) & "%'"

You tend to copy other sample code from the web, which in it self is good, but you do not understand the code at all. You then try and use the code as it was downloaded and expect it to work, ouch...;)

Edited 5 Years Ago by AndreRet: n/a

Comments
it worked ^^

not working
and doesn't have any error

my code in combobox

Select Case cmbSearch.ListIndex

Case Is = 0
Adodc1.RecordSource = "SELECT * FROM details WHERE CustomerName like '" & UCase(Trim(txtSearch.Text)) & "%'"
End Select

You do not need the trim functions etc. The search by wild character "%" looks for anything similar to the name

Adodc1.RecordSource = "SELECT * FROM details WHERE CustomerName like '" & txtSearch.Text & "%'"

I suggest you read up more on the control at this link. I still don't know why you are using the control though.

This article has been dead for over six months. Start a new discussion instead.