Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 10:45 AM
Registered User
 
Join Date: Sep 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to set focus in VBA/Word

Have multi-page user form attached to a template in VBA/Word (2000), with various check boxes, etc. on each page. Have set code behind OK button for entire user form to verify that each check box in turn has been selected and if not, to set focus to the unselected check box so user can take appropriate action. However, when I create a new doc based on the template and leave a check box unselected, I get an error message that says the focus can't be set to the check box because its invisible, not enabled, or can't receive the focus. Trouble is, every check box on every page has its visbility on and is enabled.

I have tried including page name before check box name, but nothing seems to work. Any suggestions would be most appreciated.

For example, the following does NOT work.

If chkCustomerName.value="" then
   X=MsgBox("Please ensure you peformed this action",vbOKOnly)
   chkCustomerName.SetFocus
End If

Strange thing is that when I type chkCustomerName., VBA allows me to select SetFocus as an action.

Thanks!

Larry Landis
[email protected]

Larry Landis
Technical Writer
 
Old October 28th, 2004, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Windows focus is a little unpredictable... usually I put on error resume next to catch (or ignore, like in this case) the error
Marco
BTW the value of a checkbox is not a string, the right comparison is chkCustomerName.value = vbUnchecked
BTW2 if checking boxes is mandatory, why do not check them yourself in the code?





Similar Threads
Thread Thread Starter Forum Replies Last Post
set focus sameer_1981 Intro Programming 1 February 27th, 2007 09:14 AM
set focus akibaMaila VB.NET 2002/2003 Basics 1 July 12th, 2005 05:56 PM
Set focus question crisan Access VBA 4 March 25th, 2005 09:38 PM
how to set focus waley .NET Web Services 1 May 25th, 2004 02:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.