469,125 Members | 1,835 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

After update for date field.

I have a form with a date field and a transaction number field.


The transaction number is of the format 99678*06*10*01234. The first five digits (99678) are source code. The next two digits (06) are the register number. The next two digits (10) are the year the transaction was input. Finally the last five digits (01234) are the transaction number.

When I input the date I want the want the cursor to go to the transaction number field with the source code, register number and the year already input, rest in the 10th place.


I.e., if the input date is 24-June-10, the string 99678*06*10* should be input and the cursor should be resting in the 10th position. How do it do it?


I tried this.

Expand|Select|Wrap|Line Numbers
  1. Private Sub inputDate_AfterUpdate()
  2. transNo.Value = "99678*06* &CInt(Format(inputDate(),'yy'))"
  3. End Sub
  4.  
Thanks
Apr 28 '11 #1
2 1878
colintis
255 100+
A correction to your current code first, you should place the closing double quote before the & CInt(...). Otherwise you will be seeing this code as part of your result as well. By including the cursor positioning code, it should be like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub inputDate_AfterUpdate() 
  2.  
  3. transNo.Value = "99678*06*" & CInt(Format(inputDate(),'yy')) 
  4.  
  5. transNo.SelStart = 10
  6. transNo.SelLength = 0
  7.  
  8. End Sub 
  9.  
The .SelStart is basically what you were requesting, while .SelLength specifies or determines the number of characters selected in a text box.

An additional reminder, if your cursor is placing after the 3rd set of digits, then the .SelStart should be 12.
Apr 29 '11 #2
Thanks.

It is working beautifully.

Cheers
Apr 29 '11 #3

Post your reply

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

Similar topics

4 posts views Thread by fwiest | last post: by
1 post views Thread by rkbnair | last post: by
3 posts views Thread by David | last post: by
reply views Thread by Sambhav | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.