Solved

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

Posted on 2004-04-22
3
320 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
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

756 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