473,432 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

How to set the cursor at the end of a textbox after it was SetFocus'ed?

176 100+
Hi everyone.

I wanna say first, I appritiate a lot the fact that I'm able to ask questions here!

I have a form with a textbox that if its value equals to a certain condition, a command button appears next to it. After the command button appears I need the cursor to go back to the last letter of the textbox so that the user could continue typing without interruption.

I use OnChange event for that:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CustomerName_Change()
  2.     Me.Refresh
  3.     If IsNull(DLookup("CustomerId", "tblCustomers", "CustomerName='" & Me.CustomerName & "' And CustomerSirName = '" & Me.CustomerSirName & "'")) Then
  4.         Call subResizeFmeCustomer(1)
  5.         Me.CustomerName.SetFocus
  6.     End If
  7. End Sub
  8.  
With the aforementioned code however, I get the whole textbox value being selected, so if the user will type anything, the value will be deleted.

Using
Expand|Select|Wrap|Line Numbers
  1. SendKeys "{END}"
or
Expand|Select|Wrap|Line Numbers
  1. SendKeys "{LEFT}"
at the end of that code doesn't do anything.

I wonder if there's anyway to go to the last letter of a textbox value after that textbox value has been SetFocus'ed.

Thanks for your time!!

Michael.
Oct 4 '08 #1
4 16277
missinglinq
3,532 Expert 2GB
I have to say I'm not sure about exactly what you're trying to do here, but this should set the focus on CustomerName then move the cursor to the end of the data, without anything being selected:

Expand|Select|Wrap|Line Numbers
  1. Me.CustomerName.SetFocus
  2. Me.CustomerName.SelStart = Nz(Len(Me.CustomerName), 0)
  3. Me.CustomerName.SelLength = Nz(Len(Me.CustomerName), 0)
  4.  
Linq ;0)>
Oct 4 '08 #2
Michael R
176 100+
I have to say I'm not sure about exactly what you're trying to do here, but this should set the focus on CustomerName then move the cursor to the end of the data, without anything being selected:

Expand|Select|Wrap|Line Numbers
  1. Me.CustomerName.SetFocus
  2. Me.CustomerName.SelStart = Nz(Len(Me.CustomerName), 0)
  3. Me.CustomerName.SelLength = Nz(Len(Me.CustomerName), 0)
  4.  
Linq ;0)>
Works like a charm, thanks!

(I was trying to make a certain button appear only when CustomerName fits a certain condition)
Oct 4 '08 #3
ADezii
8,834 Expert 8TB
Coming in late:
Expand|Select|Wrap|Line Numbers
  1. Me![CustomerName].SetFocus
  2. Me![CustomerName].SelStart = IIf(IsNull(Me![CustomerName]), 0, Len(Me![CustomerName]))
  3.  
Oct 4 '08 #4
missinglinq
3,532 Expert 2GB
Better late than never!

Linq ;0)>
Oct 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ed | last post by:
Hello, I posted a question about looping with Select in a While loop, a few days ago. Repliers to my post advised me that a Cursor would be much better (thanks all for your replies). I found...
3
by: robert | last post by:
don't find any mention on either udb/APARS or 390/APARS. since upgrading 390 to 7.1.1 over the weekend, the following now happens, when run from udb to 390: .... Statement stmt =...
3
by: jaYPee | last post by:
I have a form (dialog form to display report) that has an unbound textbox. I want to pass the value of this textbox to my report. But how can I pass this value if i'm accessing SQL Server 2000...
1
by: Ed West | last post by:
Hello, How can I put a textbox control into a cell of an asp:Table? I was not able to do it from the properties sheet, so I put it in via html tab, but now I can't select it from the Design tab...
2
by: Ed Bick | last post by:
Here's an easy one, I'm sure. In VB6 I would do MousePointer = vbHourGlass. How do I do this in .Net?
8
by: Patti | last post by:
I am new to SQL and have created a stored procedure for a .net web application. Unfortunately I had to use a cursor in the stored procedure, so it is taking several minutes to execute because it...
6
by: Shelly | last post by:
In looking at the asp.net TextBox, I noticed that there is a property called "OnTextChanged". I tried to use this control to call a subroutine called "GetCompanyProperties". The field is the...
26
by: Prisoner at War | last post by:
Hello, Everyone: Is there any other values or whatever-it's-called to the cursor property in CSS?? So far, I only know of cursor:pointer (or, for MSIE, cursor:hand).... Any way to load in...
36
by: CK | last post by:
How do I write a set based query? I have a groupSets table with fields setId, idField, datasource, nameField, prefix, active Data: 1,someIDfield, someTable, someField, pre1, 1 2,someotherIDfield,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.