Results 1 to 3 of 3
  1. #1
    thesugger is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2012
    Posts
    1

    Find Menu


    Hi All
    I have a search menu where users are able to search by using the name of a client. This then displays the Name, DOD and discharge date. However I would like to slightly alter it.
    I'm wanting teams to be able to search only for names within their teams, however i want a second option where if the names are in the other teams i want them to be shown in a second field.
    At the moment I have one list box which displays all the names, regardless of names.
    I have included the VB coce that I'm using.

    Private Sub Command6_Click()
    Dim DB As DAO.Database
    Dim rs As DAO.Recordset
    Dim sqlStr As String
    Dim strFill As String
    Dim l As Long
    Dim k As Long
    Dim s As String

    Set DB = CurrentDb()
    strFill = ""
    If Len(Me!Text4) > 0 Then

    sqlStr = "SELECT [forename] & "" "" & [Surname]& "" (D.O.B.) "" & [dob] & "" (Discharge Date) "" & [DischargeDate] & "" "" AS dat, patientID FROM tblPatients WHERE ((([FOREname] &[SURNAME] & [dob]) Like ""*" & Me!Text4 & "*"")) order by [SURname]"

    Debug.Print sqlStr
    Set rs = DB.OpenRecordset(sqlStr)
    If rs.RecordCount > 0 Then
    Do Until rs.EOF
    l = Len(rs!dat)
    s = ""
    For k = 1 To l
    If Mid(rs!dat, k, 1) <> "," Then s = s & Mid(rs!dat, k, 1)
    Next k

    strFill = strFill & s & ";" & rs!PatientID & ";"
    rs.MoveNext
    Loop
    Else
    MsgBox "Search Text was not found", vbOKOnly, "CYPSS Database"
    End If
    rs.Close
    End If

    Set rs = Nothing
    DB.Close
    Set DB = Nothing
    If Len(strFill) > 2048 Then stfill = Left(strFill, 2048)
    Me!List0.RowSource = strFill



    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Why do you concatenate the fields?
    You may get some ideas from the free video tutorial
    http://www.datapigtechnologies.com/f...earchform.html

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

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

Similar Threads

  1. Menu on a form
    By chauhan8787 in forum Forms
    Replies: 2
    Last Post: 02-17-2012, 02:59 PM
  2. Menu Bar for Forms?
    By cap.zadi in forum Forms
    Replies: 1
    Last Post: 12-27-2011, 01:20 PM
  3. Access Menu
    By Azeez_Andaman in forum Forms
    Replies: 2
    Last Post: 11-27-2011, 07:44 PM
  4. Menu Bar
    By graviz in forum Forms
    Replies: 0
    Last Post: 02-23-2010, 09:04 AM
  5. customized menu bar
    By marianne in forum Access
    Replies: 13
    Last Post: 04-12-2009, 09:47 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