Results 1 to 3 of 3

Thread: Microsoft Access creating a List box

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    10

    Microsoft Access creating a List box

    New to access trying to create the following list box see attached pic

    i dont know how to link the search criteria to the to the List box
    And on the bottom you will notice option buttons so if user wants to
    search by account # user selects option button called Account# and so forth.

    You will notice a command button called find patient. Once command button is pressed opens the form called Search Patient

    when user selects patient user clicks on go to patient
    this part works find






    I placed everything under the detail section of the form
    I have the following code

    Private Sub List12_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Account #] = " & Str(Nz(Me![List12], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub


    Private Sub Go_To_Record_Click()
    On Error GoTo Err_Go_To_Record_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Patient Info"
    stLinkCriteria = "[Account #]=" & Me![Account #]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_Go_To_Record_Click:
    Exit Sub

    Err_Go_To_Record_Click:
    MsgBox Err.Description
    Resume Exit_Go_To_Record_Click

    End Sub
    Private Sub Exit_Click()
    On Error GoTo Err_Exit_Click


    DoCmd.Close

    Exit_Exit_Click:
    Exit Sub

    Err_Exit_Click:
    MsgBox Err.Description
    Resume Exit_Exit_Click

    End Sub



    Any Ideas Please Help.
    Attached Files Attached Files

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    10

    Re: Microsoft Access creating a List box

    Its not pic related just a list box search

  3. #3
    Addicted Member Quizton's Avatar
    Join Date
    Dec 2005
    Location
    VB Forums
    Posts
    209

    Re: Microsoft Access creating a List box

    Here is a search that will display findings into your listbox If you need code for the listbox as well post again and Ill get that on here to!
    vb code_____________________________________
    Private Sub txtSearch_Change() <---you can change to a cmdclick if needed
    If txtSearch.Text = vbNullString Then
    sSQL = "SELECT * from EMPDATA " <--This is my table set yours,
    Set rs = db.OpenRecordset(sSQL)
    Else
    Set rs = db.OpenRecordset("SELECT * FROM EMPDATA WHERE ID LIKE '" & txtSearch.Text & "*'") <--Change to your table and change ID to your record
    End If
    list <-- Will display the found record in the listbox
    End Sub
    Last edited by Quizton; Dec 26th, 2005 at 01:37 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
  •  



Click Here to Expand Forum to Full Width