Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Text Box Set Focus Issue

I have a form with some text boxes used to capture some
text input. After the input box is updated I test the
value in a Function called DataOwnerNameValid. If I fail
the validation test I give the user a message. I then want
to return the cursor to the Input box so the user can
reenter the data.

I tried the earlier suggestion as follows but now get an
error message:

Private Sub DataOwnerInputBox_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
If DataOwnerForm.DataOwnerInputBox = "" Then Exit Sub
xOwner = DataOwnerForm.DataOwnerInputBox
OwnerOK = DataOwnerNameValid(xOwner)
If OwnerOK = False Then
MsgBox "The Data Owner Name must be in the format:
Lastname, Firstname. Your input is - " & xOwner & " - and
does not meet the format required. Try again or cancel.",
vbExclamation, "Data Owner Name Invalid"
DataOwnerForm.DataOwnerInputBox.Cancel = True
End If
End Sub

Now I get an error message:

Could not set the cancel property. Member not Found.



Subject: Text Box on User Form Set Focus Issue
From: "Tom Ogilvy" Sent: 9/6/2003
7:21:41 AM

Use the Exit event and set cancel = True if the entry is
not valid.

--
Regards,
Tom Ogilvy

John Flynn wrote in message
...
I have a form with some text boxes used to capture some
text input. After the input box is updated I test the
value in a Function called DataOwnerNameValid. If I fail
the validation test I give the user a message. I then

want
to return the cursor to the Input box so the user can
reenter the data. To do this I use the following command:

DataOwnerForm.DataOwnerInputBox.SetFocus

But it doesn't work. The next input box or other control
on the form is selected. What is the right way to do

this?

Thank you

Private Sub DataOwnerInputBox_AfterUpdate()
If DataOwnerForm.DataOwnerInputBox = "" Then Exit Sub
OwnerOK = DataOwnerNameValid
(DataOwnerForm.DataOwnerInputBox)
If OwnerOK = False Then
MsgBox "Not Valid Name", vbExclamation, "Data
Owner Name Invalid"
DataOwnerForm.DataOwnerInputBox.SetFocus
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Text Box Set Focus Issue

John,

Cancel isn't a property of the text box, it is a parameter passed to the
Exit procedure. Change the line
DataOwnerForm.DataOwnerInputBox.Cancel = True
to
Cancel = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com




"John Flynn" wrote in message
...
I have a form with some text boxes used to capture some
text input. After the input box is updated I test the
value in a Function called DataOwnerNameValid. If I fail
the validation test I give the user a message. I then want
to return the cursor to the Input box so the user can
reenter the data.

I tried the earlier suggestion as follows but now get an
error message:

Private Sub DataOwnerInputBox_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
If DataOwnerForm.DataOwnerInputBox = "" Then Exit Sub
xOwner = DataOwnerForm.DataOwnerInputBox
OwnerOK = DataOwnerNameValid(xOwner)
If OwnerOK = False Then
MsgBox "The Data Owner Name must be in the format:
Lastname, Firstname. Your input is - " & xOwner & " - and
does not meet the format required. Try again or cancel.",
vbExclamation, "Data Owner Name Invalid"
DataOwnerForm.DataOwnerInputBox.Cancel = True
End If
End Sub

Now I get an error message:

Could not set the cancel property. Member not Found.



Subject: Text Box on User Form Set Focus Issue
From: "Tom Ogilvy" Sent: 9/6/2003
7:21:41 AM

Use the Exit event and set cancel = True if the entry is
not valid.

--
Regards,
Tom Ogilvy

John Flynn wrote in message
...
I have a form with some text boxes used to capture some
text input. After the input box is updated I test the
value in a Function called DataOwnerNameValid. If I fail
the validation test I give the user a message. I then

want
to return the cursor to the Input box so the user can
reenter the data. To do this I use the following command:

DataOwnerForm.DataOwnerInputBox.SetFocus

But it doesn't work. The next input box or other control
on the form is selected. What is the right way to do

this?

Thank you

Private Sub DataOwnerInputBox_AfterUpdate()
If DataOwnerForm.DataOwnerInputBox = "" Then Exit Sub
OwnerOK = DataOwnerNameValid
(DataOwnerForm.DataOwnerInputBox)
If OwnerOK = False Then
MsgBox "Not Valid Name", vbExclamation, "Data
Owner Name Invalid"
DataOwnerForm.DataOwnerInputBox.SetFocus
End If
End Sub



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
Text cut off in Text Box. (Not a quantity issue) TanMan Excel Discussion (Misc queries) 0 February 19th 10 08:52 PM
issue with IF and text evilthorne Excel Worksheet Functions 3 January 4th 10 05:49 AM
Text Box Issue bsbm525 Excel Discussion (Misc queries) 0 July 10th 09 09:32 PM
Paste function is disabled when a text box has the focus alanleecohen Excel Discussion (Misc queries) 0 January 25th 07 08:02 PM
Text Box on User Form Set Focus Issue John Flynn Excel Programming 0 September 6th 03 02:41 PM


All times are GMT +1. The time now is 09:53 PM.

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"