#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Userform question

How do you select an item on a user form?

This is incorrect - txbFaceAmt.Select

But it would be great if this worked.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Userform question

Try

Me.txbfaceamt.SetFocus

Brad wrote:

How do you select an item on a user form?

This is incorrect - txbFaceAmt.Select

But it would be great if this worked.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Userform question

Unfortunately that didn't work - when I put in

me.facecheck.setfocus - it gave an error
facecheck.setfocus - didn't do anything.

Code
Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call FaceLimitCheck(txbFaceAmt)
End Sub

Sub FaceLimitCheck(Facecheck)
If Not (Facecheck = vbNullString) Then
If Not (IsNumeric(Facecheck)) Then
MsgBox ("Invalid entry please use numbers")
Facecheck.Value = ""
Facecheck.SetFocus
Else
If Facecheck < 25000 Then
MsgBox ("Minimum face amount is 25,000")
Facecheck.Value = ""
Else
Facecheck.Value = Format(Facecheck, "$ #,##0,000")
End If
End If
End If
Call CheckTotalFace
End Sub




--
Wag more, bark less


"Dave Peterson" wrote:

Try

Me.txbfaceamt.SetFocus

Brad wrote:

How do you select an item on a user form?

This is incorrect - txbFaceAmt.Select

But it would be great if this worked.


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Userform question

What is facecheck?

I thought you wanted to set the focus to txbfaceamt?

======
But even simpler would be to change that FaceLimitCheck into a Function that
returns a boolean--if it's ok, then return true

Then you could use:

Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
dim OkToLeave as boolean
oktoleave = FaceLimitCheck(txbFaceAmt)
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if
End Sub

This:
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if

Can be replace with a single line:
cancel = (not oktoleave)




Brad wrote:

Unfortunately that didn't work - when I put in

me.facecheck.setfocus - it gave an error
facecheck.setfocus - didn't do anything.

Code
Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call FaceLimitCheck(txbFaceAmt)
End Sub

Sub FaceLimitCheck(Facecheck)
If Not (Facecheck = vbNullString) Then
If Not (IsNumeric(Facecheck)) Then
MsgBox ("Invalid entry please use numbers")
Facecheck.Value = ""
Facecheck.SetFocus
Else
If Facecheck < 25000 Then
MsgBox ("Minimum face amount is 25,000")
Facecheck.Value = ""
Else
Facecheck.Value = Format(Facecheck, "$ #,##0,000")
End If
End If
End If
Call CheckTotalFace
End Sub

--
Wag more, bark less

"Dave Peterson" wrote:

Try

Me.txbfaceamt.SetFocus

Brad wrote:

How do you select an item on a user form?

This is incorrect - txbFaceAmt.Select

But it would be great if this worked.


--

Dave Peterson
.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Userform question

I see where you used FaceCheck.

I'd still use the Cancel argument that's built into the _exit procedure.

Dave Peterson wrote:

What is facecheck?

I thought you wanted to set the focus to txbfaceamt?

======
But even simpler would be to change that FaceLimitCheck into a Function that
returns a boolean--if it's ok, then return true

Then you could use:

Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
dim OkToLeave as boolean
oktoleave = FaceLimitCheck(txbFaceAmt)
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if
End Sub

This:
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if

Can be replace with a single line:
cancel = (not oktoleave)

Brad wrote:

Unfortunately that didn't work - when I put in

me.facecheck.setfocus - it gave an error
facecheck.setfocus - didn't do anything.

Code
Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call FaceLimitCheck(txbFaceAmt)
End Sub

Sub FaceLimitCheck(Facecheck)
If Not (Facecheck = vbNullString) Then
If Not (IsNumeric(Facecheck)) Then
MsgBox ("Invalid entry please use numbers")
Facecheck.Value = ""
Facecheck.SetFocus
Else
If Facecheck < 25000 Then
MsgBox ("Minimum face amount is 25,000")
Facecheck.Value = ""
Else
Facecheck.Value = Format(Facecheck, "$ #,##0,000")
End If
End If
End If
Call CheckTotalFace
End Sub

--
Wag more, bark less

"Dave Peterson" wrote:

Try

Me.txbfaceamt.SetFocus

Brad wrote:

How do you select an item on a user form?

This is incorrect - txbFaceAmt.Select

But it would be great if this worked.

--

Dave Peterson
.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform question [email protected] Excel Discussion (Misc queries) 0 May 29th 09 12:01 AM
UserForm Question Stockwell43 Excel Discussion (Misc queries) 0 October 27th 08 01:02 PM
UserForm Question Mr BT[_3_] Excel Worksheet Functions 0 August 20th 07 04:56 AM
Another Userform question. ingleg Excel Discussion (Misc queries) 1 July 6th 06 01:17 PM
Userform Question Greg B Excel Discussion (Misc queries) 3 March 10th 05 10:46 AM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"