Results 1 to 15 of 15
  1. #1
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159

    Form_Current doesn't fire when moving to first record.

    I have some code in the Form_Current event. Every time I use the Record Selectors that accompany the bottom of every normal Form, it fires the Form_Current event procedure.



    One of the controls on that Form is Combobox, hotwired to "Find a record based on the value I select..." (a common feature from the combobox wizard). Changing the record with this special combobox also reliably fires the same Form_Current feature.

    Here's the kicker: Of all the items in the combobox, if I select the very first one, it will NOT fire Form_Current.
    Again, the record selectors absolutely will fire the event when they are brought to record #1, but not the combobox. How might you workaround this?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The On Current event only fires when you navigate to a different record. If selecting the first option in the combo does not cause your single form view to navigate to another record then you can add some code to call the On Current Sub Procedure.

    It would look something like this
    Call Form_Current

    Here is the thing though, you need to find an event to place this in. I am going to guess that adding code to your combo's After Update event will not help. It does not sound like selecting the first option is changing the value of the combo. If the value of the combo does not change, the After Update event for the combo will not fire.

  3. #3
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159

    Form_current event Caveat...

    Thanks, but the situation here is that I'm definitely moving to a new record. For Clarity sake:


    - The Form_current event is fired when navigating to a new record... using the record selectors at the bottom of a form.
    - The Form_current event is fired when navigating to a new record using the combobox wizard feature... unless you plan on navigating back to the first record... in which case Form_current definitely will not fire.

    I've started a blank project as a sanity check with some bogus tables and tested this. try it and see. Where have I gone wrong?

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    So, to further clarify...if you

    1. Open the Form
    2. Use the Combobox to move to, say, Record #5, the Form_Current event fires
    3. If you then use the Combobox to move back to Record #1, the Form_Current event does not fire


    Is this the situation?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159
    Exactly. Assuming you're on combobox item #5, if you move it back to combobox item #1 "Form_Current" will not fire. If I used Record Selectors at the bottom of a form, it will fire. The only technique that avoids firing Form_Current is the use of a synched combobox going back to its first item! I've started new Databases and dummy tested this to make sure it's not unique to me.... same result.

    Here's a hint (I think) as you use a synched Combobox to move to records, keep your eyes focused closely on the surrounding controls. If you pay close attention, you'll notice that other controls "flicker" for a split second with data from record #1 before displaying when you manually selected! I'm interested to see what other people find.

    Matt

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I use combobox to input parameter to navigate records. Never had issue going to first record and firing Current event. I never use the code wizard. I never use macros.

    Would have to review your code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Using that scenario, I cannot reproduce your problem. The only thing I can think of is that the Combobox Control has become corrupted. Although we usually think of Forms or entire Databases when we speak of corruption, individual Controls, such as Comboboxes, can and do become corrupted. The test and the fix are one and the same; deleting the Control then re-creating it! If it was corrupt, you've verified the fact and solved the problem! If not, you've only lost a minute or two!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159

    Form_Current Limitation: Proven?

    I have made a very small file proving (I think) that Form_Current will not fire if you use a combobox synched via the Wizard, provided you're navigating back to record #1 on the form.

    If I'm wrong, I'd love to hear why. Otherwise, I'm posting it so someone can hopefully learn from it, it seems even the more experienced members here are unaware of this issue.

    I'll mark the thread as "solved" soon, since I've chosen a different way to skin the cat in my actual program. Any last moment feedback appreciated, especially to those of you who've chosen to help me earlier.

    Matt
    FormCurrentFail.accdb

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Never doubted you. Never used SearchForRecord method, not even in VBA. I seem to remember exploring it some years ago and not liking it.

    I tested by using static parameter ("[ID] = 1"). If it is 1 the Current event does not fire, it will with other numbers. I even converted the macro to VBA. Same issue.

    I agree, very bizarre.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    It apparently has to do with the use of the Embedded Macro, but like most of the developers, here. I never use Macros and don't know enough about them to even guess. But if you delete the Macro and replace it with standard, Wizard-generated Event Procedure code

    Code:
    Private Sub Combo17_AfterUpdate()
        ' Find the record that matches the control.
        Dim rs As Object
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID] = " & Str(Nz(Me![Combo17], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    the problem disappears. I suppose this would be considered to be a bug.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    It's not just the macro. I tried the SearchForRecord method in VBA and it still exhibits the issue. I use code like that in Linq's last post. Only without declaring and setting recordset object. Either way works.

    Don't understand why using Str().

    Private Sub Combo17_AfterUpdate()
    ' Find the record that matches the control.
    With Me.Recordset.Clone
    .FindFirst "[ID] = " & Nz(Me![Combo17], 0)
    If Not .EOF Then Me.Bookmark = .Bookmark
    End With
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    AccessDenial is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    8
    I am facing the exact same issue. Has anyone found a solution to this since OP tackled the problem through a different method?

    My form has 2 ways of navigating: (1) Combobox for navigation (2) Arrows for previous and next record.

    Form_Current() does not run ONLY when i use the combobox navigation to go back to Record 1.

    Have tried deleting my navigation Combobox and AfterUpdate but they don't work.

  13. #13
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    I can't reproduce your problem. How, exactly, are you creating this Combobox...using the 3rd argument in the Combobox Wizard...using code?

    What is the code in your Form_Current event?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    @AccessDenial, really should have started your own thread and referenced this old one. New thread would likely get more attention.

    I visited the posted db again. The Current event fires when form first opens and this is for record 1. However, it does not fire again for record 1 when returning to it.

    Still find this odd and still do not understand it.

    So only solution I know is to not use the original SearchForRecord code (macro or VBA): DoCmd.SearchForRecord , "", acFirst, "[ID] = " & Str(Nz(Screen.ActiveControl, 0))

    and replace with:

    Private Sub Combo17_AfterUpdate()
    Me.RecordsetClone.FindFirst "ID=" & Me.Combo17
    If Not Me.RecordsetClone.NoMatch Then Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    therentabrain is offline Novice
    Windows 7 64bit Access 2002
    Join Date
    Jan 2019
    Posts
    1
    This is a known bug in Access 2007 and 2010, apparently.

    https://answers.microsoft.com/en-us/...f-4fbb739b1dc0

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 12-03-2013, 01:25 PM
  2. Replies: 4
    Last Post: 12-14-2012, 06:33 PM
  3. Replies: 3
    Last Post: 09-19-2012, 07:34 AM
  4. Trying to fire event on record change
    By danielhowden in forum Forms
    Replies: 3
    Last Post: 05-13-2011, 06:30 AM
  5. Form_Current Event
    By Bubi in forum Forms
    Replies: 6
    Last Post: 02-22-2011, 11:16 AM

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