Sabtu, 27 Oktober 2012

[ExcelVBA] XL2007 Unable to select Form TextBox with code

 


I have a TextBox in a form. When a value that is past a limit is entered, I pop up an error message box.

When the message box is dismissed, another item in the form is selected and the user must re-select the TextBox text to enter the corrected value.

When the message box is dismissed, I'd like to have the TextBox entry selected so the user simply starts typing.

As it is now putting the "." after the TextBox name brings up the Intellisense choices, but none will select the text. There is no SetFocus or anything similar.

Suggestions?

Steve N.

Preempting someone asking, Here's the Sub:

The textbox in question is named "Mem_LastMM"
-------------------------------------------
Private Sub Mem_LastMM_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Debug.Print "MM 7 Mem_LastMM_BeforeUpdate()"

If Val(Mem_LastMM) < Val(Mem_FirstMM) Then
MsgBox "The LAST memory must be equal to or greater than FIRST memory", , " Error in Memory Number"
' What can I put here to select Mem_LastMM ...?
If D700 Then
Mem_LastMM = 200
Else ' D7
Mem_LastMM = 199
End If
Exit Sub
End If

If D700 Then
If Mem_LastMM > 200 Then Mem_LastMM = 200
Else ' D7
If Mem_LastMM > 199 Then Mem_LastMM = 199
End If

End Sub

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar