Can't Get The Cursor in the Box!!! (1 Viewer)

themurph2000

Fat, drunk, and stupid
Local time
Yesterday, 18:38
Joined
Sep 24, 2007
Messages
181
I know this is an easy one, but I can't get it to work. :banghead: I have a form where, if you double-click on a text box, a smaller form will pop up and it has a single text box where you can type in a number, hit [ENTER], and search for the number you typed in the table the first form is based on. The trouble is I can't get SetFocus to place the cursor in the box. I know this doesn't sound like much, but if someone starts typing right away, they could ruin the data in the table.

This should be easy, but Forms!frmsearchJCN!searchidnumber.SetFocus just isn't working, whether I put in in the OnLoad event of frmsearchJCN or put it in as part of the double-click in the other form, which opens up that form box.

Any thoughts?
 

veraloopy

Registered User.
Local time
Today, 00:38
Joined
Apr 10, 2009
Messages
139
In form design mode, check the properties of the searchidnumber field, look at the Other tab and make sure the 'Tab Stop' is set to Yes
Then check the Tab Order of the form and move this field to the top.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:38
Joined
Feb 19, 2002
Messages
43,257
You shouldn't need .SetFocus to move the cursor. When the form opens, the cursor will be sitting in the first enabled, unlocked control. If it isn't check your control properties and the tab order for the section. For example if there are three data entry fields on the form and the form opens with the cursor in #2, it is because the tab order is incorrect. You can alter it manually if you have a complex form and you want to override the "normal" order or you can click on the Tab order button to bring up a dialog that lets you just reorder the controls or you can drag them up or down to place them out of order.
 

themurph2000

Fat, drunk, and stupid
Local time
Yesterday, 18:38
Joined
Sep 24, 2007
Messages
181
Unfortunately, the Tab Stop is set to "yes" and the text box is the only thing in the form, so there's no tab order to fix. Also, taking the SetFocus command out of the VB code didn't have any effect.

However, if I use a button instead of double-clicking on the text box, I get the cursor where I need it. I wonder if using the OnDoubleClick property might have been the problem. :confused:

Thanks for the replies.
 

cplmckenzie

Registered User.
Local time
Yesterday, 19:38
Joined
Apr 29, 2012
Messages
27
themurph2000,

if the smaller form that pops up is not a subform then try this.

In the Form Open type...

Me.searchidnumber.setfocus

Where Me refers to the main object ... the small form.

cplmckenzie
 

Users who are viewing this thread

Top Bottom