Results 1 to 4 of 4
  1. #1
    Adish is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2015
    Posts
    15

    use pop up form to display search results

    Hi All. I have 2 search boxes in my main form where users can enter the customers name and search. I want to open another pop up window/form which displays all the names of the customer which are same e.g display all john smith and then the user can select the correct one from the pop up window seeing further details like dob and ph#'s. I don't know hoe to do this in access and VBA. any help would be appreciated.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Options:

    1. VBA to build filter criteria and apply to form when it opens, review http://www.allenbrowne.com/ser-62.html

    2. dynamic parameterized query as form RecordSource (I never do this)
    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
    Adish is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2015
    Posts
    15
    My Code is

    Code:
    If Me.UserInput = "" Then
        MsgBox "Enter Surname to Search", vbInformation, "Surname Required"
        Me.UserInput.SetFocus
    Exit Sub
    ElseIf Me.FirstName = "" Then
        MsgBox "Enter First Name to Search", vbInformation, "First Name Required"
        Me.FirstName.SetFocus
    Exit Sub
    Else
        
        On Error GoTo myError
        Dim strNAMESearch As String
            strNAMESearch = "dbo_NUCNAME.GIVEN_NAMES like '" * " & Me.FirstName & " * "'" & " AND " & "dbo_NUCNAME.NAME like '" * " & Me.UserInput & " * "'"
            
            strSQL = "SELECT dbo_NUCADDRESS.*, dbo_NUCSTREET.STREET_NAME, dbo_NUCMEMO.text1, dbo_NUCMEMO.memo_type, dbo_NUCMEMO.Status " _
                & "FROM ((dbo_NUCADDRESS INNER JOIN dbo_NUCSTREET ON dbo_NUCADDRESS.STREET_NO = dbo_NUCSTREET.STREET_NO) INNER JOIN dbo_NUCMEMO ON dbo_NUCADDRESS.PROPERTY_NO = dbo_NUCMEMO.TABLE_NO)" _
                & "INNER JOIN (dbo_NUCNAME INNER JOIN dbo_NUCASSOCIATION ON dbo_NUCNAME.NAME_CTR = dbo_NUCASSOCIATION.KEY2) ON dbo_NUCADDRESS.PROPERTY_NO = dbo_NUCASSOCIATION.KEY1 " _
                & " WHERE " & strNAMESearch ' & " AND " & MEMO_TYPE & " AND " & Memo_Status
            
            Debug.Print strSQL
            DoCmd.OpenForm "Owner Details", , , strNAMESearch
            Forms.Item("Owner Details").RecordSource = strSQL
    leave:
            Exit Sub
    myError:
            MsgBox Error$
        Resume Next
    I do get the form to open up but no records are displayed. not sure what's wrong in my code. I do get this in my immediate window which is correct but does not display in pop up form.

    SELECT dbo_NUCADDRESS.*, dbo_NUCSTREET.STREET_NAME, dbo_NUCMEMO.text1, dbo_NUCMEMO.memo_type, dbo_NUCMEMO.Status FROM ((dbo_NUCADDRESS INNER JOIN dbo_NUCSTREET ON dbo_NUCADDRESS.STREET_NO = dbo_NUCSTREET.STREET_NO) INNER JOIN dbo_NUCMEMO ON dbo_NUCADDRESS.PROPERTY_NO = dbo_NUCMEMO.TABLE_NO)INNER JOIN (dbo_NUCNAME INNER JOIN dbo_NUCASSOCIATION ON dbo_NUCNAME.NAME_CTR = dbo_NUCASSOCIATION.KEY2) ON dbo_NUCADDRESS.PROPERTY_NO = dbo_NUCASSOCIATION.KEY1 WHERE dbo_NUCNAME.GIVEN_NAMES like 'John' AND dbo_NUCNAME.NAME like 'Smith'

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Why are you setting form RecordSource?

    Why would you use strNAMESearch in both the constructed SQL statement and in the OpenForm argument?

    How many customers are there? Why not just a combobox listing customers on the main form?

    I have never seen Item property used.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  2. Replies: 5
    Last Post: 01-03-2013, 01:38 PM
  3. Display QUERY results into SUB FORM
    By taimysho0 in forum Programming
    Replies: 9
    Last Post: 11-23-2011, 12:26 PM
  4. Replies: 1
    Last Post: 07-21-2011, 01:57 PM
  5. Form to display results
    By Zholt in forum Forms
    Replies: 9
    Last Post: 05-07-2009, 10:09 AM

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