Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thank you for the best reply I've ever had to a forum question - it's extremely comprehensive and legible and answers my query thoroughly..."

Geography

Where in the world do Tek-Tips members come from?
1DMF (Programmer)
12 Apr 12 6:21
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

RuralGuy (TechnicalUser)
21 Apr 12 21:06
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

1DMF (Programmer)
22 Apr 12 6:06
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")

    Do Until Not IsLoaded("inputPopUp")
        DoEvents
    Loop


    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

RuralGuy (TechnicalUser)
22 Apr 12 9:24
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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close