set text/value property of a text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone,

I have a unbound form (frmlookup) that contains a text box (Mysearch) and a
subform (sfrmlookup). The text box is mentioned in the subform underlying
query Criteria for MatrialName: Like "*" & [Mysearch] & "*". When you type
in the text box it requeries the subform but only after you hit enter. Is
there a way to make the subform requery every time something is typed in the
text box without hitting enter or losing focus? Like if someone types in 8,
it requeries and brings up every name that contians an 8 in, then a 5 is
typed in and it bring up every name with an 85 in it.

Thanks
 
You can try calling Requery in the Change event of the text box. This can
get tricky, though. For example, if the text box contains the single digit
'8', and the user backspaces out the '8' before typing a '7', the Change
event will fire after backspacing the '8' and before typing the '7', which
is probably not what you want. You might want to add some code to test that
the text box contains a valid value before calling Requery. Something like
....

If Len(Me!NameOfTextBox & vbNullString) > 0 Then
If IsNumeric(Me!NameOfTextBox) Then
Me.Requery
'Or Me.NameOfSubFormControl.Requery, as appropriate
End If
End If
 
Back
Top