Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection from Listbox to GoTo Record in Bound form Gives Error 2105

Status
Not open for further replies.

DB_Bowes

Programmer
Apr 21, 2022
2
US
I have a bound form to a SQL Server table. On that same form I have a listbox that gets distinct loan numbers from that table. The listbox has 2 columns, the PK and the loan number. I used the following code to display the record on the bound form they selected in the listbox so that they can edit it if needed.

This was working great until all of a sudden it stopped working for no reason and I get Error 2105 "You can't go to the specified record."

What am I doing wrong?

Private Sub lst_LocalLoanNumberList_Click()
DoCmd.GoToRecord acDataForm, "frm_LocalLoanInfo", acGoTo, Me.lst_LocalLoanNumberList.Column(0)
End Sub

I have tried putting the PK into a variable, same error.
 
This worked:

Private Sub lst_LocalLoanNumberList_Click()

Dim pk_index As Integer

pk_index = Me.lst_LocalLoanNumberList.Column(0)

With Form_frm_LocalLoanInfo.Recordset
.FindFirst "LocalLoanNumberID =" & pk_index

Form_frm_LocalLoanInfo.SetFocus

If .NoMatch Then
MsgBox "Not found!"
End If

End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top