• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VisualBasic for Applications

AtlantaBob

Golden Member
Two quick questions, of course, answers can't be found in Microsoft Help.

In VBA (host app is Access 2003), how do I automatically move the cursor to the end of a memo field when a form opens? As it is, all of the text is selected when the form opens, and I don't want someone to easily overwrite the text if they're not paying attention.

Also, how do I automatically select all of the text in a combo box whenever the user clicks inside the text box component?

I realize it will be an oncick or onfocus event (or something of the sort), but how could I write the code to select everything -- or just clear the contents entirely? (onclick, then set the variable of the combobox to "" ? I'll try that, but I'd rather just select all of the text, so someone could click again and edit the text if the needed to.

Thanks in advance.
 
To move the cursor to the end of the memo field:
In the form Load event add code like

Me.txtbox.SelStart = Len(Me.txtbox.Text)

For number two in the onfocus event add something like
Me.txtbox.SelStart = 0
Me.txtbox.SelLength = Len(Me.txtbox.Text)
 
Back
Top