Please help me in solving this error of my project.
This error appear when i enter this character [
it shows me that i enter an invalid string.
where particularly is the error? does it concern with the keyascci?
thanks for ur help.

Where do you enter the string ? Textbox? Combobox?

its in the textbox sir

Do you have any code in the key events of the textbox? If yes, do show what you have done sofar.

HERE IS MY CODE:

Private Sub txtsearchbook_Change()

If cmbsearchbook.Text <> "" Then
adobooksearch.RecordSource = "SELECT * from tblbooks where " & cmbsearchbook & " like '%" & Replace(txtsearchbook.Text, "'", "''") & "%'"
adobooksearch.Refresh
Else
adobooksearch.RecordSource = "SELECT * from tblbooks" 'where Author like '%" & "#" & "%'"
adobooksearch.Refresh
End If
End Sub


Private Sub txtsearchbook_GotFocus()
DataList2.ListField = cmbsearchbook



If cmbsearchbook = "" Then
MESS = MsgBox("select category first", vbInformation + vbOKOnly, "search")
    If MESS = vbOK Then
    cmbsearchbook.SetFocus
    txtsearchbook = ""
    End If
Else
DataList2.Visible = True
End If
If txtsearchbook <> "" Then
    txtsearchbook.SelStart = 0
    txtsearchbook.SelLength = Len(txtsearchbook.Text)
End If
End Sub


Private Sub txtsearchbook_KeyPress(KeyAscii As Integer)
If KeyAscii = 123 Or KeyAscii = 125 Then
MsgBox "Invalid Character"
End If

Your lines 34 to 37 are fine. Which line throws the error?

its in th eline 5 the error occurs.

I can't see where you open or close your database. So I suggest you check your select statement and check that your database is open etc. On second thoughts you might want to validate the string that comes from the textbox.

How can i validate the string in the textbox?
is it possible that only numbers nd letters are allowed in the textbox?

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.