Minggu, 28 Oktober 2012

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

 

A quick Google search shows a few useful pages.

One I like is the EnterFieldBehavior property, which should cause the field
to highlight every time it's entered, not just after an error.

There also seem to be SelStart and SelLength properties, that would allow
part (or all) of the text to be selected.

Possibly other ways too, I just looked at the first few Google hits.

Regards, Dave S

----- Original Message -----
From: "noskosteve" <noskosteve@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Monday, October 29, 2012 12:59 PM
Subject: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code

>
> Thank you Dave.
> That helps a bit, but after trying many things, I obviously was confused
> and I mis spoke inside my question. I meant to say that there is no
> "Select" (not SetFocus). My Subject was correct.
> Inserting Cancel.Value = True leaves the cursor in the text box at the
> right of the entry, but the entry text is not selected. The user must
> either backspace, or dbl click to select the bad entry.
> I was hoping to have the entry selected so the user only needed to type
> the new value. Is that possible?
>
> Steve N.
>
>
> --- In ExcelVBA@yahoogroups.com, "David Smart" <smartware.consulting@...>
> wrote:
>>
>> 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@...>
>> 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
>> >
>>
>
>
>
>
> ------------------------------------
>
> ----------------------------------
> 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/5359 - Release Date: 10/28/12
>

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