Subform - Removing Highlight OnOpen

Sorrells

Registered User.
Local time
Today, 20:28
Joined
Jan 13, 2001
Messages
258
Greetings,

This is a problem that has been plaguing me for months. Tonight I thought I had it. It worked in AccessXP fine until I compacted the database, then the same old problem.

I have a main form with a subform set to Continuous Forms. It is populated by a query but is not related to the main form.

When the main form is opened, the record selected in the subform is highlighted. I want it not to be highlighted but have the cursor blinking on the left side of the text.

From the google newsgroups I found some code that worked at first, but as noted above, could not withstand the compaction/repair. I got no errors, it just stopped working!

Here is the code at the end of the OnOpen event of the form. I also tried it in the OnCurrent and in both but to no avail.


Forms![frmEnter_Tasks]![subfrmEnter_Tasks].SetFocus
Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SetFocus

SendKeys "{F2}"
SendKeys "{HOME}"

I am simply blown away that this could work for a while and then abjectly, totally fail. Any advice will be most appreciated. :confused:
 
Using "On Got Focus" for the field in question, try:

Me.TextBoxName.SelStart = 0


To select the end of the field you can use:

Me.TextBoxName.SelStart = Me.TextBoxName.SelLength



Note: If you want this feature for all fields, You can set this as a default option in Tools / Options / Keyboard


Hope I am on the right track.

Brad.
 
Brad,

I got a response on UtterAcces that preceded you. The solution was a little different as follows:
================
Forms![frmEnter_Tasks]![subfrmEnter_Tasks].SetFocus
Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SetFocus
Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SelStart = 0
========================

But I will look into yours as I update the subform with various controls on the main form, not just the OnOpen event. I'll get back to you on that.

But it is certainly the right track! Thanks so much for responding!
:D
 

Users who are viewing this thread

Back
Top Bottom