Go To Record Dialog Box

T

tmac

I have a form "frmUpdateBrwr" with a button that opens another form
"frmSearch". The second form "frmSearch" has a listbox named List0. I want to
be able to select a name in the listbox and then click a command button and
go to that record in the "UpdateBrwr" form. The code in the command button
click event produces an error. When I go to the debugger, List0 is
highlighted and I get the message "method or data member not found". The code
behind the button's click event is

Private Sub cmdGoToRecord_Click()

Dim rst As Recordset
Set rst = Forms!frmUpdateBrwr.RecordsetClone

rst.FindFirst "IDB = " & List0
Forms!frmUpdateBrwr.Bookmark = rst.Bookmark
DoCmd.Close acForm, "frmSearch"

End Sub

I would REALLY appreciate any help you can give with this.

Thanks,
tmac
 
A

Allen Browne

For debugging purposes, break the failing line into 2:

Private Sub cmdGoToRecord_Click()
Dim rst As Recordset
Dim strWhere As String
Set rst = Forms!frmUpdateBrwr.RecordsetClone
strWhere = "IDB = " & Me.List0
rst.FindFirst strWhere
'...

Now, which line fails? If the strWhere line fails, List0 is not the name of
your listbox.

If the rstFindFist line fails, the string is malformed. That could happen if
nothing is selected in the list box. Or, if the Bound Column of the list box
refers to a field of type Text (not Number), you need extra quotes in the
previous line:
strWhere = "IDB = """ & Me.List0 & """"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top