Results 1 to 4 of 4

Using Find & FindNext in a form

Threaded View

  1. #1
    Registered User
    Join Date
    05-04-2005
    Location
    Papamoa, New Zealand
    MS-Off Ver
    Office 365
    Posts
    56

    Using Find & FindNext in a form

    Hi,

    Can someone please help me here - trying to get Find and FindNext to work within to populate data within a form to enable it to be edited.

    I have many records with the same number in Col A in the database and this seems to work in finding the first record and then the next but not after that.



    Private Sub CommandButton1_Click()

    Dim Loc As String

    Loc = Format(TextBox1.Value, "####")

    Sheets("Sheet1").Select
    Cells.Find(What:=Loc, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate


    With Worksheets("Sheet1")
    Set C = .Range("A:A").Find(Loc, LookIn:=xlValues)

    If Not C Is Nothing And .Cells(C.Row, 1) <> Loc Then firstAddress = C.Address
    Do
    Set C = .Range("A:A").FindNext(C)
    Loop While Not C Is Nothing And .Cells(C.Row, 1) <> Loc And C.Address <> firstAddress

    TextBox2 = .Cells(C.Row, 2)
    TextBox3 = .Cells(C.Row, 3)
    End With

    End Sub

    Cheers,
    Bernz
    Last edited by BernzG; 08-14-2005 at 10:54 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1