Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unbound field not remembering input

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I have an unbound input field, which I use an onkeyup event to do a filter against a subform.

EG, CompanyName, as you type in the input field, the results are filtered as you type... well that's the plan..

However, I've done a msgbox as you type, and the box is only ever equal to the first character you type, although the on screen display shows the characters you type, the value of the input is only ever the first character typed.

If I use a me!refresh, the cursor highlights all text in the input field and so as you type you keep replacing the text in the input field.

What is going on? why is the form behaving like this and how do I get it to function the way I want?

Thanks,

1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
it's ok worked it out thanks.

You don't use...

Me!fieldname

you use....

Me!fieldname.Text

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
but it only works if the field has focus!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Well, surely the textbox will have control if you're querying the OnKeyUp event. I'd use the OnChange Event anyway. Here's a working example that filters a ListBox, but the idea is the same and you should be able to change the code fairy easily.

Code:
Private Sub txtListFilter_Change()
    lstFiltered.RowSource = "SELECT fldKey, fldOrganisation FROM tblTrainers WHERE fldOrganisation like '*" & txtListFilter.Text & "*'"
End Sub

I used to be the Comaboy on Tek-Tips.

...And the despicable Jeremy Vyle elsewhere. ;)
 
my actual final code was this...

Code:
Private Sub Company_Change()
    Forms!hlp_search.search_results.Form.Filter = "CompanyName like '*" & Forms!hlp_search.Company.Text & "*' AND [Membership Number] like '*" & Forms!hlp_search.MembNo & "*' AND LastName like '*" & Forms!hlp_search.Surname & "*'"
    Forms!hlp_search.search_results.Form.FilterOn = True
End Sub

It works really well, everyone is loving the new interface :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top