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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup Form (modal) -- Textbox Issues

Status
Not open for further replies.

dBjason

Programmer
Mar 25, 2005
355
US
Access 2007 SP 1

Hello,

I have a pop-up modal form that is used as a lookup form.

In the form header, I have a textbox where the user can enter the beginning part of an address.

In the detail section (continuous forms), address/city/state/zip are listed.

In the textbox on_change event, the following code executes:
Me.Filter = "Address LIKE '*" & me.txtFindAddress & "*'"
Me.FilterOn = True


It almost works, but I've run into one problem. After the filter is applied, the focus is sent back to txtFindAddress with the search criteria highlighted.

This results with the user only being able to filter on a single character, after the on_change event executes for the first character it becomes highlighted and then changed when the user enters the second character.

IE: I can only filter on "B" or "L" but not "BL" as B will become highlighted and changed to L after the next keystroke.

I tried using SendKeys {Right} after FilterOn but to no avail.

Any help would be greatly appreciated!

Thanks,
Jason

 
Use the AfterUpdate event instead.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Have you tried to use the SetFocus command to move the focus to another control?

Code:
Private Sub textbox_change()
  Me.Filter = "Address LIKE '*" & me.txtFindAddress & "*'"
  Me.FilterOn = True 
  Me.SomeOtherControl.SetFocus
End Sub

But of course, that's going to deselect the text box with every keystroke...

If you want to use the SendKeys command, how about sending the {End} key... would that work any different?

The only thing with using SendKeys is it can be dangerous. If the user happens to do anything else on their pc that changes the focus just before it triggers, the wrong application can be in focus.

--

"If to err is human, then I must be some kind of human!" -Me
 
Antway, in a textbox's Change event procedure I'd use the Text property instead of the Value ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, it worked with a combination of that and SendKeys!
 
How are ya dBjason . . .
dBjason said:
[blue] ... it worked with a combination of that and [purple]SendKeys![/purple][/blue]
[purple]SendKeys![/purple] [surprise] ... No! No! No! No! No! ... Bad programming . . . Baaaaadd! . . .

So ... lets see ... hmmm ... rem out or delete, all you've tried for this secnario. Then in the [blue]On Change[/blue] event of [blue]txtFindAddress[/blue], copy/paste the following:
Code:
[blue]   Dim ctl As Control
   
   Set ctl = Me!txtFindAddress
   
   Me.Filter = "[Address] LIKE '*" & ctl.Text & "*'"
   Me.FilterOn = True
   ctl.SelStart = Nz(Len(ctl.Text), 0)
   
   Set ctl = Nothing[/blue]
Perform your testing!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
dBjason said:
Thanks, it worked with a combination of [highlight]that
and SendKeys![/QUOTE]

Could you be more specific about your that? Just wanted to be sure.

Thanks

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top