Solved

Error 2115 when setting focus to textbox; Select all text in control

Posted on 2004-04-22
3
324 Views
Last Modified: 2012-06-21

I am trying to set focus to a control after it has been populated by recordset...the following does not work. I want to also have all text selected --
control a does not seem to work in access

Set rst1 = InventoryDb.OpenRecordset(strRS)
If rst1.RecordCount > 0 Then
If rst1("Comments") <> "" And Not IsNull(rst1("Comments")) Then
[txtProComments] = "LAST COMMENT:" & rst1("Comments")
rst1.Close
Me.Refresh
[txtProComments].SetFocus
SendKeys ("_")
0
Comment
Question by:pdidow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 125 total points
ID: 10892271
Try:
me.[txtProComments].SetFocus

Nic;o)
0
 

Author Comment

by:pdidow
ID: 10892828
No good. get the error message:

run-time error '2108'
you must save the field before you can execute the GoToControl action,
the GoToControl method, or the SetFocus Method...
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10893174
I'm missing some endif statements, but try:

Set rst1 = InventoryDb.OpenRecordset(strRS)
If rst1.RecordCount > 0 Then
  If rst1("Comments") <> "" And Not IsNull(rst1("Comments")) Then
   me.txtProComments = "LAST COMMENT:" & rst1("Comments")
 endif
endif
rst1.Close
Me.Refresh
me.txtProComments.SetFocus
SendKeys ("_")

Nic;o)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question