Results 1 to 3 of 3
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Go to a record on a continuous form based on value entered in a text box

    I have a bound subform (frmTheData) that is displayed as a continuous form. I would like to add a text box (ID) in its footer that when a unique ID number is entered into it and then the “Find” button (cmdFind) is pressed, it goes to the record (field name = ID) matching that ID. I would assume the arrow on the navigation bar would point to it.



    The subform’s record source is a query (qryTheData) that connects all the related tables and displays relevant fields in the subform. I want all these records to remain displayed. I do not want to display just that record. I only want to jump to it.

    Ideas on how to do this using VBA?

    Using Access 2007.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I use RecordsetClone and bookmarks for this. Example:

    Code:
        With Me.RecordsetClone
            .FindFirst "LabNum='" & Me.cbxLabNum & "'"
            Me.Bookmark = .Bookmark
        End With
    Does main form have data? Is the subform linked to data on main form? Are there other subforms? If main form has no data and this is only subform, why use subform and not just put all on one form? If it is linked, you are aware that the subform cannot show records not associated with the main form record?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    It turned out subform was locked down and I couldn't enter anything into the textbox, so this is the work around that I found.

    Code:
    Private Sub cmdFind_Click()
        Dim number As Integer
        Dim rs As Object
        
        number = InputBox("Enter ID number :")
        Set rs = Me.Recordset.Clone
        
        rs.FindFirst "[ID]= " & number
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    
        If number <> Me!ID Then
              MsgBox "No number matches", vbOKCancel
        Else
              MsgBox "Yea, you matched a number", vbInformation
        End If
    End Sub
    Thank you for your help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 01-07-2014, 09:33 AM
  2. Replies: 2
    Last Post: 01-01-2014, 02:10 PM
  3. Replies: 2
    Last Post: 11-30-2013, 02:53 AM
  4. Replies: 3
    Last Post: 05-26-2011, 12:52 PM
  5. Automatic checkbox based on value entered in form
    By w00tage19 in forum Database Design
    Replies: 2
    Last Post: 07-12-2010, 04:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums