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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving to a record in a form from another form

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
US
I want to be able to move to record in another while working on the current
form. The current form has the identical recordset. I'm trying the code
below but I get an invalid book mark error.
****************code starts here********************
Code:
Public Function GotoData(sFieldName As String, rs As DAO.Recordset,
sValueToCheck As String) As Boolean
    Dim sSearchPart As String
    Dim rsClone As DAO.Recordset

    On Error GoTo errHandler

    'iterate through recordset until we find a match
    Set rsClone = rs
    With rsClone
        If Not (.BOF And .EOF) Then .MoveLast
        If .RecordCount = 0 Then Exit Function
        .MoveFirst
        Do While Not .EOF
            'watch for blanks
            If Not IsNull(.Fields(sFieldName)) Then
                'search for match of only the amount typed in
                sSearchPart = Left$(.Fields(sFieldName), Len(sValueToCheck))
                If LCase(sValueToCheck) = LCase(sSearchPart) Then
                    rs.Bookmark = rsClone.Bookmark
                    Forms(msFrmName).Bookmark = rsClone.Bookmark
'**Error Invalid Bookmark here**
                    GotoData = True
                    Exit Function
                End If
            End If
            .MoveNext
        Loop
    End With
errHandler:
     Exit Function
***************************************************************
where msFrmName is a variable holding the name of the calling form. I want
to be able to move to this record in the calling form but I'm having
difficulty as I get an invalid bookmark (the form is open). Does anyone
know why I get this message and/or how to move to a specific in another form
based on current record in this form.

Thanks,
Rewdee


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top