JS-Q5: Run time error 2105

  • Thread starter Thread starter Jack Sheet
  • Start date Start date
J

Jack Sheet

Uff. Still having problems (Access 97)

I created a very simple form, that simply displays all of the fields in a
table, as text boxes with one exception which is a combo box. The idea is
to select a record from a drop-down list in the combo box, rather than using
the bar at the bottom of the form.

When I select a new record from the drop-down list I get the run time error
2105, and when I debug the row "Me.Bookmark...." is highlighted in yellow in
the following code. Any takers? Thanks.

Sub Combo50_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Ref] = '" & Me![Combo50] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
 
I think I have a kludgy solution to this.
The problem appears to stem from the fact that I tried to set the combo box
to enable it to accept a new record. If I disable that option in the combo
box and then create a separate text box on the form for entering the same
field for a new record then it seems to work. Looks naff, though. Would
have preferred just one field on the form, then if I click on new record
that field would be blank and enable the user to enter the details direct
into the combo box.
 
Are you sure that the FindFirst is actually finding anything?

Sub Combo50_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Ref] = '" & Me![Combo50] & "'"
If Me.RecordsetClone.NoMatch = True Then
MsgBox "I couldn't find " & Me![Combo50]
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub

It may be necessary to use Me.RecordsetClone.MoveFirst before you use the
FindFirst method.
 
Thanks, but it bombed out at the same line with same error message.
Not to worry, as you can see from my other post I have sort of given up on
that idea.

Douglas J Steele said:
Are you sure that the FindFirst is actually finding anything?

Sub Combo50_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Ref] = '" & Me![Combo50] & "'"
If Me.RecordsetClone.NoMatch = True Then
MsgBox "I couldn't find " & Me![Combo50]
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub

It may be necessary to use Me.RecordsetClone.MoveFirst before you use the
FindFirst method.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jack Sheet said:
Uff. Still having problems (Access 97)

I created a very simple form, that simply displays all of the fields in a
table, as text boxes with one exception which is a combo box. The idea
is
to select a record from a drop-down list in the combo box, rather than using
the bar at the bottom of the form.

When I select a new record from the drop-down list I get the run time error
2105, and when I debug the row "Me.Bookmark...." is highlighted in yellow in
the following code. Any takers? Thanks.

Sub Combo50_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Ref] = '" & Me![Combo50] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
 
Back
Top