Link to home
Start Free TrialLog in
Avatar of Norbert2000
Norbert2000Flag for Afghanistan

asked on

Error 2115 finding record

Hi Experts,

I have 2 listboxes, one giving a subset of the other.   I want to be able to click on the second listbox, and then show that individual record in the fields on my form.

Using:

Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[OrdersDeliveryID] = " & Str(Me![DeliveryListbox])
Me.Bookmark = rs.Bookmark

This works.

However, I'd like to set the first listbox so that if I click a record, it goes to the first record in the second listbox, and displays the data.  

So, this should work:

Private Sub BreakdownListbox_AfterUpdate()
'Me.OrdersBreakdownRef = Me.BreakdownListbox
'Me.OrdersRef = Forms!Orders!OrdersID
Me.DeliveryListbox.Requery
If Me.DeliveryListbox.ListCount = 0 Then
'if empty new record?
Else
With Me.DeliveryListbox
     .Selected(1) = True
     .Value = .ItemData(1)
End With
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[OrdersDeliveryID] = " & Str(Me![DeliveryListbox])
Me.Bookmark = rs.Bookmark
End If
End Sub

However I get an 2115 error, which I understand means the record is already being updated - I just don't know how to get round it.

Any ideas?
Avatar of puppydogbuddy
puppydogbuddy

try this and see if it helps:
change both occurences of the following:
          rs.FindFirst "[OrdersDeliveryID] = " & Str(Me![DeliveryListbox])
To:
         rs.FindFirst "[OrdersDeliveryID] = '" & Str(Me![DeliveryListbox]) & "'"

ASKER CERTIFIED SOLUTION
Avatar of jefftwilley
jefftwilley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Norbert2000

ASKER

Jeff,

Commenting out     .Selected(1) = True worked - so thanks for a point in the right direction!