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.

Edited 1 Year Ago by Reverend Jim: Please do not post in ALL CAPS

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

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.

Edited 1 Year Ago by Minimalist: second thought

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

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