Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2004, 10:45 AM
Registered User
Join Date: Sep 2003
Location: Tulsa, Oklahoma, USA.
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)
End If

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


Larry Landis

Larry Landis
Technical Writer
Reply With Quote
  #2 (permalink)  
Old October 28th, 2004, 03:06 PM
Friend of Wrox
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts

Windows focus is a little unpredictable... usually I put on error resume next to catch (or ignore, like in this case) the error
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?
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

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

All times are GMT -4. The time now is 10:01 PM.

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