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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

event procedures

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I seem to be having issues with event procedures and focusing on form fields.

It seems that if within an event procedure I call another global function which focuses on a form field and moves the carret to the end, as the code eventually goes back to the event procedure call, if I do anything else within the event procedure the text highlighted in the form field is random and peculiar?

If the event procedure after calling the global function does nothing else the correct point in the focused field is where the carret is placed.

Is this normal?

Is it something to do with being an event handler call rather than a standard function/sub call.

It only seems to behave like this if done within an event handler as described?

Thanks
1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Electronic Dance Music Downloads
 
In what event are you calling this "global function" and what is the function?

(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 ac10 - winXP Pro, Win7 Pro
Please respond to this forum so all may benefit
 
I worked it out thanks.

I was trying to pause the event procedure

Code:
   Private Sub docNotes_DblClick(Cancel As Integer)

    Call inputZoom("Documents Request Notes")

    [b]Do Until Not IsLoaded("inputPopUp")
        DoEvents
    Loop[/b]

    If bPopZoomChanged Then
    
        Call setDocs(Me.Docs_Form.Form, Me.Adviser)
        
        If Nz(Me.docNotes, "") <> "" Then
            Me.docNotes.SetFocus
            Me.docNotes.SelStart = Len(Me.docNotes)
        End If
    
    End If
    
End Sub

Then continue when form closed, bad practice!

So changed it to make the selection on form close instead like so
Code:
Private Sub Form_Close()

    If bPopZoomChanged And oControl.Name = "docNotes" Then
        [Forms]![Check_Docs].Last_Check = Format(Now(), "yyyy/mm/dd")
        [Forms]![Check_Docs].Checked_By = oUser.Name
    End If
    
    oControl.SetFocus
    If Not IsNull(oControl) Then
        oControl.SelStart = Len(Me.inputTextBox)
    End If
    
End Sub
Works fine now.

I guess you must let event procedures complete as quick as possible, not try to pause them as I was doing.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Electronic Dance Music Downloads
 
Glad to hear you got it sorted.

(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 ac10 - winXP Pro, Win7 Pro
Please respond to this forum so all may benefit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top