Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subforrm - Removing Highlighted Record OnOpen

Status
Not open for further replies.

Sorrells

Programmer
Dec 28, 2000
92
0
0
US
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:


Regards, Sorrells
 
Replace the SendKeys statements with this:

Code:
Forms![frmEnter_Tasks]![subfrmEnter_Tasks]![txtTaskName].SelLength = 0

FWIW, you could use the shorthand method of referring to the current form, i.e. Me instead of Forms![frmEnter_Tasks]

HTH...

Ken S.
 
Ken,

Thanks for your reply. The command worked fine! I did not realise that these properties were available. Another small step forward for this old man!

Regards, Sorrells
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top