Bookmark not finding correct record in Combo Box

freem500

Registered User.
Local time
Today, 08:43
Joined
Apr 23, 2007
Messages
19
Hello,

I'm using a combobox to list payee names and then type the name into the combobox with the autocomplete to allow for quick jumping between records. The problem is the AfterUpdate event on the combobox uses a VBA Bookmark to jump to the selected record. This doesn't seem to be working properly. On some of the records it jumps to an incorrect record - as far as I can see it is fine unless I'm trying to locate a record towards the bottom of the list (the combo box has 25 list rows, with almost 700 records).

Set rs = Me.Recordset.Clone
rs.FindFirst "[fldPayeeID] = " & Str(Nz(Me![cboPayeeName], 0))
If rs.NoMatch Then
MsgBox "Payee Name Not Found!", vbExclamation
Me![cboPayeeID] = Null
Me![cboPayeeID].SetFocus
Exit Sub
End If

'Synchronise PayeeID With Name Selected
Me![cboPayeeID] = cboPayeeName

If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If​

The odd thing is that cboPayeeName is correct at the point before If Not rs.EOF but when I debug.print after the End If it is no longer correct. I can't work it out at all!

Thanks for any help you can offer.
 
OK, I've just answered my own question - I hadn't realised that the Current event was triggered, but of course it will be triggered when the focus moves to the new record ... and there is code in there that was resetting the PayeeID.

Thanks anyway!
 

Users who are viewing this thread

Back
Top Bottom