Sabtu, 27 Oktober 2012

Re: [ExcelVBA] XL2007 Unable to select Form TextBox with code

 

I believe you will find that the text box does have a SetFocus method. I
can see it when I put the "." after the textbox name. (Excel 2003).

However, that's not how you handle a problem found by BeforeUpdate. You
simply want to cancel the update and this will keep the user in the box.

Cancel.Value = True

(If you try selecting the textbox in the BeforeUpdate, it won't do anything,
seeing the box is already selected. And once the update is complete, you'll
get the same movement you would have got if there had been no problem.)

Regards, Dave S

----- Original Message -----
From: "noskosteve" <noskosteve@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Sunday, October 28, 2012 1:37 PM
Subject: [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
>
>
>
> ------------------------------------
>
> ----------------------------------
> 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
>
> ----------------------------------Yahoo! Groups Links
>
>
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1427 / Virus Database: 2441/5356 - Release Date: 10/26/12
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
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