Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Neutrino is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    11

    Oncurrent event too fast?

    Hi, I'm a newbie and have a quick question. I have introduced an "Oncurrent event" in order to check if two textbox have the same value. My code does not work but when I go step by step it does!!! Do you think the code is too fast so that the form doesn't have enough time to refresh? Here is the simple code:

    Private Sub Form_Current()

    If Me.SumaDebe = Me.SumaHaber Then
    MsgBox "ok", vbOKOnly
    Else
    MsgBox "error", vbOKOnly
    End If

    End Sub

    Any ideas? Thanks

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    define STEP BY STEP

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Neutrino View Post
    Hi, I'm a newbie and have a quick question. I have introduced an "Oncurrent event" in order to check if two textbox have the same value. My code does not work but when I go step by step it does!!! Do you think the code is too fast so that the form doesn't have enough time to refresh? Here is the simple code:

    Private Sub Form_Current()

    If Me.SumaDebe = Me.SumaHaber Then
    MsgBox "ok", vbOKOnly
    Else
    MsgBox "error", vbOKOnly
    End If

    End Sub

    Any ideas? Thanks
    Not a chance but are you aware that when the form loads you may get more than one CurrentEvent? How about if you simply use the navButtons and switch records? Does it work then?

  4. #4
    Neutrino is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    11
    Sorry ajetrumpet, by step by step I mean that I put a breakpoint F9 in the first line of the code "If Me.SumaDebe = Me.SumaHaber Then" then I go step by step by using F8 and I find that it works...weird!!

  5. #5
    Neutrino is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    11
    Quote Originally Posted by RuralGuy View Post
    Not a chance but are you aware that when the form loads you may get more than one CurrentEvent? How about if you simply use the navButtons and switch records? Does it work then?
    I am using the nav buttons to move through records and does not work.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Neutrino View Post
    I am using the nav buttons to move through records and does not work.
    In that case there is something else going on. I assume these are two Controls on your form. Are they both bound to fields in the RecordSource of the form? If not, what is the ControlSource of those two controls?

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    that's strange. I remember a while back I heard about something like this with message boxes, but I can't remember now.

    I just tested the same thing with a continuous form and it works fine, both with using rec selectors and navs, or changing via mouse or TAB on the keyboard.

    is this on a network?

    have you tried using a new form to try and combat a corruption issue?

    <edit>
    It looks like you've intrigued us both. Try Ruralguy's first, he will probably cover the most common mistakes made, as I tend to stray right to the complex stuff.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    We'll see what the reply is but I'm guessing a Domain Function in one of the ControlSources.

  9. #9
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by RuralGuy View Post
    We'll see what the reply is but I'm guessing a Domain Function in one of the ControlSources.
    Would that be the reason for the code executing faster than the population of the value? I remember seeing that complaint somewhere, but couldn't remember the reason.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm not certain how the Tasker works but Domain Functions take longer that controls bound to fields so right now that is my best guess. I'm surprised the OP has not responded yet.

  11. #11
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    The OP is at lunch.

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Ahh...you're right, I'm hungry too.

  13. #13
    Neutrino is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    11
    Quote Originally Posted by RuralGuy View Post
    In that case there is something else going on. I assume these are two Controls on your form. Are they both bound to fields in the RecordSource of the form? If not, what is the ControlSource of those two controls?
    Sorry, I was at lunch. Both textbox are bound to a Subform that is embedded in this "Form". The textboxes get their value by adding records within the "Subform". So the answer is no, they are not bounded to recordSource of the form.

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Neutrino View Post
    Sorry, I was at lunch. Both textbox are bound to a Subform that is embedded in this "Form". The textboxes get their value by adding records within the "Subform". So the answer is no, they are not bounded to recordSource of the form.
    You are *definately* fighting a timing issue with the Tasker within Access. To make it work as you have it you either need to reference the SubForm directly instead of waiting for Access to resolve all of the indirections or place the values on the MainForm yourself in code.

  15. #15
    Neutrino is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    11
    Quote Originally Posted by RuralGuy View Post
    I'm not certain how the Tasker works but Domain Functions take longer that controls bound to fields so right now that is my best guess. I'm surprised the OP has not responded yet.
    The Textboxes take a fraction of a second to calculate, so it seems that the "Oncurrent" event is faster and gets me "OK" all of the time. When I run it through the breakpoint F9 (and use F8 to go step by step), it seems that I'm giving it the extra time needed to refresh the textbox and gives the correct answer everytime. I'm thinking about putting some time of delay so that to give the Textbox time to "refresh"....but not sure how.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 12-16-2010, 02:46 PM
  2. Replies: 1
    Last Post: 12-05-2010, 02:34 AM
  3. OnCurrent error
    By dreamweaver547 in forum Security
    Replies: 1
    Last Post: 03-14-2010, 01:45 PM
  4. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  5. Access Database size Grows too fast
    By no-e in forum Access
    Replies: 0
    Last Post: 12-16-2008, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums