Microsoft Office Forums .setfocus not working why?

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2011, 02:52 AM
Cbrehm Cbrehm is offline .setfocus not working why? Windows 7 64bit .setfocus not working why? Office 2003
Novice
.setfocus not working why?
 
Join Date: May 2011
Posts: 8
Cbrehm is on a distinguished road
Default .setfocus not working why?



Code:
Private Sub addcophone_Enter()
If IsError(Application.Match(addcozip, Range("zipcode").Columns(1), 0)) Then
    addcozip.SetFocus 'does not work
End If
End Sub
In userforms.textfields why can I not setfocus from a textbox but can from a command button?

In the following setfocus is not available at all.


Code:
Sub addzip(ByVal zipfield As MSForms.TextBox, ByVal cityfield As MSForms.TextBox, ByVal statefield As MSForms.TextBox)
    'carl brehm 05-08-2011
    'zip is zipcode entered in field afterupdate
    'zipfield is thee name of textbox for the zip code
    'cityfield is the name of the textbox for the city
    'statefield is the name of the textbox for the state
' zip code
Dim zip As Double
 If zipfield = Empty Then Exit Sub
 
zip = zipfield.Value 'get zipcode entered

    If IsError(Application.Match(zip, Range("zipcode").Columns(1), 0)) Then
        zipfield.Value = Empty 'value not found make user reenter
        cityfield.Value = Empty
        statefield.Value = Empty
        MsgBox ("That was not a valid Zip Code")
        'STATEFIELD.SETFOCUS NOT AVAIABLE HERE
        Exit Sub
    Else
        'lookup city and state to prefill textbox
        cityfield.Value = Application.WorksheetFunction.VLookup(zip, Range("zipcode"), 2, False)
        statefield.Value = Application.WorksheetFunction.VLookup(zip, Range("zipcode"), 3, False)
    End If

End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Acrobat add-in not working gdancoleman Word 0 08-07-2010 06:10 PM
.setfocus not working why? Can't get AND function working Scaffold Excel 6 07-09-2010 01:41 AM
DocumentBeforePrint not working maruapo Drawing and Graphics 0 06-15-2010 12:31 PM
Spellchecker not working GR8Fandini Word 6 02-07-2010 01:12 PM
working with html kate1234 Word 0 09-22-2008 05:02 PM


All times are GMT -7. The time now is 07:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft