Snowflake68
Registered User.
- Local time
- Today, 11:46
- Joined
- May 28, 2014
- Messages
- 464
I have the following code in the AfterUpdate event of a text box on a form. It check to see if the user has removed the value and to prevents it from being null. The code populates the text box with 123456789 if its null. I then want the user to be able to overwrite the highlighted text.
The above code keeps the focus by setting it to another control before returning the focus back to the TraderVATNumber text box but it wont keep the text highlight. I can see that it momentarily highlights the text but then the cursor just goes to the end of the text. So I know my code is working but I just need to find a way of keeping it highlighted
Any help would be greatly appreciated.
Code:
If IsNull([TraderVATNumber]) Then
MsgBox "Please enter a valid Trader VAT Number", vbCritical, "#ERROR - TRADER VAT NUMBER"
TraderVATNumber.Value = "123456789"
StatusFlag.SetFocus
TraderVATNumber.SetFocus
TraderVATNumber.SelStart = 0
TraderVATNumber.SelLength = Len(Me.TraderVATNumber)
End If
The above code keeps the focus by setting it to another control before returning the focus back to the TraderVATNumber text box but it wont keep the text highlight. I can see that it momentarily highlights the text but then the cursor just goes to the end of the text. So I know my code is working but I just need to find a way of keeping it highlighted
Any help would be greatly appreciated.