Norbert2000
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_AfterUpda te()
'Me.OrdersBreakdownRef = Me.BreakdownListbox
'Me.OrdersRef = Forms!Orders!OrdersID
Me.DeliveryListbox.Requery
If Me.DeliveryListbox.ListCou nt = 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?
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_AfterUpda
'Me.OrdersBreakdownRef = Me.BreakdownListbox
'Me.OrdersRef = Forms!Orders!OrdersID
Me.DeliveryListbox.Requery
If Me.DeliveryListbox.ListCou
'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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Jeff,
Commenting out .Selected(1) = True worked - so thanks for a point in the right direction!
Commenting out .Selected(1) = True worked - so thanks for a point in the right direction!
change both occurences of the following:
rs.FindFirst "[OrdersDeliveryID] = " & Str(Me![DeliveryListbox])
To:
rs.FindFirst "[OrdersDeliveryID] = '" & Str(Me![DeliveryListbox]) & "'"