non-firing Form_Current on new record selected by listbox

  • Thread starter BBC via AccessMonster.com
  • Start date
B

BBC via AccessMonster.com

Access 2007 I am selecting records on a form via a listbox. The
Form_Current event fires on opening the form (1st record is selected by
default) and fires on the selection of all records selected via the ListBox
EXCEPT when re-selecting the very first record again (after going to another
record). It DOESN'T fire only when using the the ListBox, using my
navigation buttons always causes the Form_Current to fire on moving to
another record (even going back to the first record).
The ListbBox always selects & diplays the correct record, 1st or otherwise

The code for the ListBox is (using After_Update event)
DoCmd.SearchForRecord , "", acFirst, "[ClientID] = " & Str(Nz(Screen.
ActiveControl, 0))

Typical record navigation code is
DoCmd.GoToRecord , "", acNext

any thoughts or suggestions
 
D

Dirk Goldgar

BBC via AccessMonster.com said:
Access 2007 I am selecting records on a form via a listbox. The
Form_Current event fires on opening the form (1st record is selected by
default) and fires on the selection of all records selected via the
ListBox
EXCEPT when re-selecting the very first record again (after going to
another
record). It DOESN'T fire only when using the the ListBox, using my
navigation buttons always causes the Form_Current to fire on moving to
another record (even going back to the first record).
The ListbBox always selects & diplays the correct record, 1st or otherwise

The code for the ListBox is (using After_Update event)
DoCmd.SearchForRecord , "", acFirst, "[ClientID] = " & Str(Nz(Screen.
ActiveControl, 0))

Typical record navigation code is
DoCmd.GoToRecord , "", acNext

any thoughts or suggestions


I don;t know why that would be, and don't have my A2007 PC turned on at the
moment, but you might check if different code for your list-box navigation
makes a difference. For example, I would code it this way:

'----- start of example code -----
Private Sub lstYourListbox_AfterUpdate()

With Me.lstYourListbox

If Not IsNull(.Value) Then
Me.Recordset.FindFirst "ClientID=" & .Value
End If
End With

End Sub
'----- end of example code -----

If that code works and doesn't show the misbehavior you report, I would
conclude it's some quirk of DoCmd.SearchForRecord, though I haven't heard of
that before.
 
B

BBC via AccessMonster.com

I also had another place on my form where I switched between client and their
"partner" using this technique and it also failed. I changed both to your
suggestion and they both work fine now.
Thanks
... again...
Brian

Dirk said:
Access 2007 I am selecting records on a form via a listbox. The
Form_Current event fires on opening the form (1st record is selected by
[quoted text clipped - 15 lines]
any thoughts or suggestions

I don;t know why that would be, and don't have my A2007 PC turned on at the
moment, but you might check if different code for your list-box navigation
makes a difference. For example, I would code it this way:

'----- start of example code -----
Private Sub lstYourListbox_AfterUpdate()

With Me.lstYourListbox

If Not IsNull(.Value) Then
Me.Recordset.FindFirst "ClientID=" & .Value
End If
End With

End Sub
'----- end of example code -----

If that code works and doesn't show the misbehavior you report, I would
conclude it's some quirk of DoCmd.SearchForRecord, though I haven't heard of
that before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top