Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Setfocus on textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason - 26 May 2008 10:09 GMT
Dear all,

I want to set the focus in the one textbox even if I press <enter> or <tab>
key until I use the mouse to point to another textbox. How can I do ?

Thank you

Jason.
Douglas J. Steele - 26 May 2008 12:44 GMT
Why would you hit the Tab key? Tabs don't work in Access controls...

To stay in the same textbox when hitting Enter, set the EnterKeyBehavior
property for the text box.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Dear all,
>
[quoted text clipped - 5 lines]
>
> Jason.
Rob Parker - 26 May 2008 13:54 GMT
Hi Doug,

Why wouldn't you hit the Tab key?  Unless you've set tab stop to No for
every control on your form, the Tab key will cycle through the controls
(move focus to the next control in the tab order); it may even move to the
next record, depending on the Cycle property setting for the form itself.

I think the OP needs to put code into the KeyDown event for the control in
question, and do nothing if the key code is either 9 (tab key) or 13 (enter
key).  It's not something I've ever done, so I don't know exactly what is
needed to cancel the key's action (the KeyDown event doesn't have a Cancel
parameter), but it shouldn't be too hard.

Rob

> Why would you hit the Tab key? Tabs don't work in Access controls...
>
[quoted text clipped - 10 lines]
>>
>> Jason.
Douglas J. Steele - 26 May 2008 15:30 GMT
You're right. I was reading it as he wanted to be able to insert tabs into
the text.

Jason: Set the KeyPreview property of the form to True, and add code like
the following to the KeyPress event of your textbox:

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case KeyCode
   Case 9, 13
     KeyCode = 0
   Case Else
 End Select
End Sub

(replace Text0 with the actual name of your text box)

Note that the above means that the Enter key will be ignored. If you want
the Enter key to put a carriage return/line feed into your text, remove the
", 13" from the code above, and set the EnterKeyBehavior property as I
previously suggested.

Sorry for the confusion.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi Doug,
>
[quoted text clipped - 25 lines]
>>>
>>> Jason.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.