Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now