Hello, I have a problem maybe you guys can help me with.
I have a text field, and I did those code for it:
Private Sub SearchRecord_KeyUp(KeyCode As Integer, Shift As Integer)
dim strSQL As String
dim search As String
search = Me.searchField
strSQL = "SELECT [Mytable].[mycolumn], [Mytable].[mycolumn2] FROM [Mytable] WHERE [Mytable].[mycolumn] = '" & search & "';"
Me.ListBox1.RowSource = strSQL
Me.ListBox1.Requery
End Sub
As I type it in it doesn't seem to change the RecordList list box. When I put in a message boxlike this:
MsgBox ("anything doesn't matter")
Me.ListBox1.RowSource = strSQL
Me.ListBox1.Requery
End Sub
It works, and it brings lists my query in the list box as I type, which is what I like, but it keeps bringing up the annoying MsgBox. So what I did is, I removed the text box, and tried running it again (didn't work again), so I type in the query without the last letter, so instead of "Smith" I typed in "smit" then I right-clicked (in form view) the list box and hit Properties. I didn't change anything just closed the properties again, as I typed in "h" to finish "Smith" it found it and displayed it (worked). When I deleted the whole thing in the text box and no matter what I type it still doesn't change the text box (even though it should make it blank because it didn't find anything), so it remains Smith it found last time and wont' get refreshed. When I hit properties and close it and as I type in another letter it querries it (something that it wouldn't find results for) and it erases my old Smith entry, and displays no results (what it should do).
This is very weird and it somehow needs some user acknolwedgement or something in order to change the row source of this object, regardless if it is a property box or a message box. Is there any way I can make it work without the message box and not having to right-click properties anc close it every time I type in a letter for it to work propertly?
Thank you very much for your help iin advance.
I have a text field, and I did those code for it:
Private Sub SearchRecord_KeyUp(KeyCode As Integer, Shift As Integer)
dim strSQL As String
dim search As String
search = Me.searchField
strSQL = "SELECT [Mytable].[mycolumn], [Mytable].[mycolumn2] FROM [Mytable] WHERE [Mytable].[mycolumn] = '" & search & "';"
Me.ListBox1.RowSource = strSQL
Me.ListBox1.Requery
End Sub
As I type it in it doesn't seem to change the RecordList list box. When I put in a message boxlike this:
MsgBox ("anything doesn't matter")
Me.ListBox1.RowSource = strSQL
Me.ListBox1.Requery
End Sub
It works, and it brings lists my query in the list box as I type, which is what I like, but it keeps bringing up the annoying MsgBox. So what I did is, I removed the text box, and tried running it again (didn't work again), so I type in the query without the last letter, so instead of "Smith" I typed in "smit" then I right-clicked (in form view) the list box and hit Properties. I didn't change anything just closed the properties again, as I typed in "h" to finish "Smith" it found it and displayed it (worked). When I deleted the whole thing in the text box and no matter what I type it still doesn't change the text box (even though it should make it blank because it didn't find anything), so it remains Smith it found last time and wont' get refreshed. When I hit properties and close it and as I type in another letter it querries it (something that it wouldn't find results for) and it erases my old Smith entry, and displays no results (what it should do).
This is very weird and it somehow needs some user acknolwedgement or something in order to change the row source of this object, regardless if it is a property box or a message box. Is there any way I can make it work without the message box and not having to right-click properties anc close it every time I type in a letter for it to work propertly?
Thank you very much for your help iin advance.