Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setfocus problem..

Status
Not open for further replies.

keeyean

MIS
Sep 29, 2001
32
US
i have a SSTab1 which have 4 tabs (2 combo3 and 2 combo4 in each Tab)... and i use the code below to check the input of the SSTab1...
if have a error.. then a msgbox will pop up and then focus to the offending combobox ... but there is a bug..

eg.)if the offending combobox is at Tab0 and i'm at Tab0 then it's work... but..if i were in Tab2, then it can't setfocus to the offending combobox at Tab0

wish you can follow...

Public Sub Check_Click()
For i = 0 to 3
For j = 0 to 1
If Combo3((i * 2) + j).Text = "No" Then
If Combo4((i * 2) + j).Text = "No" Then
msg(1) = "Error!! Push button needed on " & Form4.SSTab1.TabCaption(i)
Message(1) = MsgBox(msg(1), vbCritical)
Form4.Combo4((i * 2) + j).SetFocus
Exit Sub
End If
End If
Next j
Next i

End Sub
 
I've used a timer for these kinds of situations. Set the Timer1.Enabled = false at design time or in Form_Load.
Code:
'Form Level
Private fobjFocus as object
''''

    Message(1) = MsgBox(msg(1), vbCritical)
    Set fobjFocus = Form4.Combo4((i * 2) + j)
    Timer1.Interval = 55 ' 55 milliseconds
    Timer1.Enabled = true
''''''''
Private Sub Timer1_timer()
    Timer1.Enabled = false
    If fobjFocus is Nothing then exit sub
    On error resume next   ' Do not blow app for "Nice to Have"
        fobjFocus.SetFocus
    On error goto 0
    Set fobjFocus = Nothing
End Sub
 
hmm.. .. i tried the code.. but it doesn't have any different compare to the method i used.
how does the timer work??
 
You'd have to set the tab containing the offending combo error:

form4.SSTab1.Tab = i ' select Tab#
Form4.combo4((i * 2) + j).setfocus

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top