Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Posts
    3

    Unanswered: Record find problem

    Hi,
    Im trying to do a record find in access on a form i created.
    It seems to work fine when i click the find button and input something to search for, but it doesnt seem to change to the correct record.
    here is my form code

    Private Sub cmdFind_Click()
    'Dim strClientID As String
    Dim varBookmark As Variant
    Dim strHome_Phone_Number As Variant
    Dim strsql As String

    'Store the book of the current record
    varBookmark = Me.Recordset.Bookmark

    'Attempt to locate another client
    strHome_Phone_Number = InputBox("Enter the Customers Home phone Number for the Customer you want to locate")

    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset
    strsql = "Select * from tblCustomers WHERE [LastName] = ('strHome_Phone_Number')"
    ' Establish the connection and cursor type,
    ' and open active recordset
    rst.ActiveConnection = CurrentProject.Connection
    rst.CursorType = adOpenDynamic
    rst.LockType = adLockOptimistic

    'rst.Open "Select * from tblCustomers WHERE [LastName] = ('strHome_Phone_Number')", Options:=adCmdText
    ' rst.Open "Select * from tblCustomers "
    rst.Open strsql
    MsgBox ("I am here")



    'Me.Recordset.Find "LastName = " & 'strHome_Phone_Number', Start:=1

    'If client not found, display a message and return to
    'the original record
    If Me.Recordset.EOF Then
    MsgBox "Home Phone Number " & strHome_Phone_Number & " Not Found!!"
    Me.Recordset.Bookmark = varBookmark

    'If client found, synchronize the form with the
    'underlying recordset
    Else
    Me.Bookmark = Me.Recordset.Bookmark
    End If
    End Sub

    Private Sub cmdNext_Click()

    'Move to the next record in the recordset
    Me.Recordset.MoveNext

    'If at EOF, move to the previous record
    If Me.Recordset.EOF Then
    Me.Recordset.MovePrevious
    MsgBox "Already at Last Record!!"
    End If

    'Set the bookmark of the form to the bookmark
    'of the recordset underlying the form
    Me.Bookmark = Me.Recordset.Bookmark
    End Sub

    Thanks for anyones help in advance.
    My email is
    robert.f.smith@sbcglobal.net

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    at what point do you think you are changing data in the current record / moving to a new record?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2006
    Posts
    3
    Actually i'm trying to figure out why im not moving to the record I put in to find. I havent put any code in to change a record yet?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    fine, so at what point do you think you have told the form to move to your selected recrod?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jun 2006
    Posts
    3
    Ok so how do I do that . i bleieve I was asking the same exact question?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •