Results 1 to 2 of 2
  1. #1
    Aeonem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    8

    Searching records from one form with the results showing on another form

    Hello,

    I currently have a single form set up (frmSearch) that has a search bar text box and command button (with VBA code) that enables me to search records in a table.
    I was wondering If it would be possible to use a different form (frmSearchBar) as the search bar and then the record information appearing in the form already made.
    Therefore I want the search bar form (frmSearchBar) to pop out from the (frmSearch). Once the search bar form is open, there will only be a text box and command button that will search for a record, and once the record is found, the information populates text boxes in the other form (frmSearch). While also closing the search bar form (frmSearchBar).
    The current VBA code I use at the moment is:

    Private Sub cmdSearchBar_Click()
    If IsNull(txtSearchBar) = False Then
    Me.Recordset.FindFirst "[Item]='" & txtSearchBar & "'"
    Me!txtSearchBar = Null
    If Me.Recordset.NoMatch Then
    MsgBox "No Item found", vbOKOnly + vbInformation, "Sorry"
    Me!txtSearchBar = Null


    End If
    End If
    End Sub

    txtSearchBar = the search bar text box.
    cmdSearchBar = the command button.

    I know that was a bit of a rubbish explanation but hopefully it got my problem across.

    Thanks,
    Aeonem

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I do not understand the explanation.
    You currently have a search button/search field that work as you want but you want to change it so that when you click your search button a second form pops up with a prompt for the search criteria?

    When you click the button on that new pop up form you want to then go to the appropriate record on the main form?

    If that's the case you would have to substitute the form name wherever you have ME in your current code assuming you were running it from your new form (frmSearchBar)

    I've never used the recordset.findfirst but it might be something like

    forms("frmSearch").recordset.findfirst "[Item] = '" & forms("frmSearchBar").controls("txtSearchBar").val ue

    if you're running the code from frmsearch bar you might be able to get away with

    forms("frmSearch").recordset.findfirst "[Item] = '" & txtSearchBar

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

Similar Threads

  1. Replies: 12
    Last Post: 08-17-2013, 11:49 PM
  2. Replies: 12
    Last Post: 04-07-2012, 12:09 PM
  3. Replies: 1
    Last Post: 03-09-2011, 02:04 AM
  4. Replies: 10
    Last Post: 01-10-2011, 07:52 PM
  5. Replies: 0
    Last Post: 11-10-2009, 12:06 PM

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