Form.SetFocus problem

  • Thread starter Lori2836 via AccessMonster.com
  • Start date
L

Lori2836 via AccessMonster.com

This event is part of a text box that filters a subform as a contract number
is being typed in. I tried to copy from this form, to my own.......created
the text box, changed the txt names, etc....but when I try to actually type
something into my text box, the first line is highlighted...it doesn't seem
to like the Me.Exit_Form.

Can someone explain to me exactly what that first line is doing, or saying?

Thanks,
Lori




Private Sub HeimContractRef_Change()

Me.Exit_Form.SetFocus
Me.TxtHeimContractRef.SetFocus
Me.TxtHeimContractRef.SelStart = Me.TxtHeimContractRef.SelLength + 1
DoCmd.Requery ("Search for contracts subform")
End Sub
 
D

Dirk Goldgar

Lori2836 via AccessMonster.com said:
This event is part of a text box that filters a subform as a contract
number
is being typed in. I tried to copy from this form, to my
own.......created
the text box, changed the txt names, etc....but when I try to actually
type
something into my text box, the first line is highlighted...it doesn't
seem
to like the Me.Exit_Form.

Can someone explain to me exactly what that first line is doing, or
saying? [...]

Private Sub HeimContractRef_Change()

Me.Exit_Form.SetFocus
Me.TxtHeimContractRef.SetFocus
Me.TxtHeimContractRef.SelStart = Me.TxtHeimContractRef.SelLength + 1
DoCmd.Requery ("Search for contracts subform")
End Sub

It's trying to set the focus to a control named "Exit_Form". I have no idea
why, because then it sets the focus right back to the control
"TxtHeinContractRef". Do you have a control on your form that is named
"Exit_Form"? It sounds likely to be a command button, to me.
 
L

Linq Adams via AccessMonster.com

First off, you probably shouldn't be using the OnChange event. This fires
with each character you enter into the box, which probably isn't your
intention. While I'm not real clear as to what you're trying to do, you
probably should be using the HeimContractRef_AfterUpdate event.

What is Exit_Form? The main form? The subform? If it's the subform, you need
to refer to the name of the subfom control, not the name of the supplying
form.

Where does TxtHeimContractRef.SetFocus reside, on the main for or on the
subform?
 
L

Linq Adams via AccessMonster.com

Sorry, forgot to add, you cannot set focus to a form if it has any objects
that can receive focus. If a form has a textbox, checkbox, combobox, command
button, etc, it cannot receive focus. The only exception to this would be if
allof these objects had their properties set to something, such as Visible =
False, so that they cannot (temporarily) receive focus.

A form being used as a subform ***can*** have the focus set, even if they
have these objects, because you're not actually setting focus to a form, but
rather to the subform control that holds the form.
 
L

Lori2836 via AccessMonster.com

Thanks Linq. I do want it to fire with each character entered...its
supposed to filter the part numbers in the subform as the number is entered.
For example, there may be 10 part numbers that start with LH1, and the
product manager wants to see them all. So as you type the LH, it filters out
all others. The code is actually from another unbound text box in the
database that works the same as I need my text box to work. I looked thru all
of the code, and I couldn't figure out what the Exit_Form was all about,
since I'm not that familiar with code. I did not create this database, which
is very involved and confusing....but have been given the job of updating and
maintaining it. I'm just trying to create the same thing, in a different
form. Now that I have an idea of the Exit_Form, I will go back and see if I
can find a form or command button called Exit.

Lori
 
Top