Full Version: Killer Clone
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
rmsphoto
UtterAccess is Awesome! I have learned so much, and am nearly ready to launch the database I have been working on for months...

Anyway - I thouhgt I was learning. But I am trying to use a recordset clone to "jump" to a record. I think this should be very simple - but it's killing me!

I have a form that displays several hundred records. With UA member help, I have a "jump to" list that allows me to jump to the first record of each letter of the alphabet. Now I also want to be able to pick a name from a combo box, and jump to that person's record.

So I set up this code, based on the alphabetical code from earlier:
Per_ID is the autonumber key in the tbl_Personnel table. jumpToID is the combo box that displays names, with the bound column being the Pers_ID. The form actually uses a query of several linked tables - The query uses asterices (*) to get all the table columns of each table. I get a data type mismatch when this code fires on the line: rs.FindFirst "tbl_Personnel.Pers_ID = '" & varID & "'"

CODE
Private Sub jumpToID_AfterUpdate()

btnSortByEntryDate.Value = False
Form.OrderBy = "[Pers_lastName],[Pers_firstName]"
Form.OrderByOn = True
Call IDfilter([jumpToID])

End Sub

Private Sub IDfilter(varID As Integer)

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[tbl_Personnel].[Pers_ID] = '" & varID & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub



P.S. this is the code that work for the alphabet jump to:

CODE
Private Sub jumpTo_AfterUpdate()

btnSortByEntryDate.Value = False
Form.OrderBy = "[Pers_lastName],[Pers_firstName]"
Form.OrderByOn = True
Call InitialFilter([jumpTo])

End Sub

Private Sub InitialFilter(strInitial As String)

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "Left([Pers_lastName],1) = '" & strInitial & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub
theDBguy
Hi,

What version of Access are you using? Please remember to select the version number when posting questions in case it becomes relevant to the discussion.

You're getting a type mismatch error because you are enclosing the ID variable in quotes when it's probably a number. Try simply:

rs.FindFirst "[tbl_Personnel].[Pers_ID] = " & varID

Just my 2 cents... 2cents.gif
rmsphoto
Sorry - it was 2007

I thought it had to be a simple syntax issue. I tried several different ways - I get pretty tied up when it comes to single and double quotes.

Thanks for a perfect solution once again! notworthy.gif
theDBguy
Hi,

QUOTE (rmsphoto @ May 24 2012, 07:52 PM) *
Sorry - it was 2007

No worries. I just had to mention it for consistency. Not a big deal.



QUOTE
Thanks for a perfect solution once again! notworthy.gif

yw.gif

Glad we could help. Good luck with your project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.