Solved

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

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

776 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