Serach Box!!!!!!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • THEAF
    New Member
    • Mar 2007
    • 52

    Serach Box!!!!!!!!

    hi,
    this is the code im trying to use for my search button. Just to explain on the toolbar i select search, an input box should pop up, i input the firstname on a staff then the listbox should clear and show the details. all my code does is just clear the listbox.

    Search
    [code=vb]
    Set dbmyDB = OpenDatabase("E :\skol\A2 Computing\Speed y Pizza database.mdb")
    Set rsmyRS = dbmyDB.OpenReco rdset("Staff", dbOpenDynaset)

    Dim Name As String
    Name = InputBox("Pleas e insert name", "Name")

    If Not rsmyRS.EOF Then rsmyRS.MoveFirs t
    lstRecord.Clear
    Do While Not rsmyRS.EOF
    If LCase(rsmyRS!Fi rstname) = LCase(Name) Then
    lstRecord.AddIt em rsmyRS!Firstnam e & " " & rsmyRS!Lastname & vbTab & rsmyRS!StaffID
    End If
    rsmyRS.MoveNext
    Loop
    [/code]
    CAN SOMEONE PLEASE HELP
    Last edited by debasisdas; Feb 14 '08, 10:49 AM. Reason: added code=vb tags.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    What is the problem with this code ?

    Comment

    • THEAF
      New Member
      • Mar 2007
      • 52

      #3
      Originally posted by debasisdas
      What is the problem with this code ?
      ohm, the problemwas that the list kept clearing instead of showing the result.
      Anyway just to let you know i got it fix. the problem was with my list box
      this the solution:

      Old
      rsmyRS.FindFirs t "StaffID=" & Str(lstRecord.I temData(lstReco rd.ListIndex))
      then the rest.....

      Solution
      rsmyRS.FindFirs t " StaffID =" & Str(Split(lstRe cord.List(lstRe cord.ListIndex) , vbTab)(1))

      this is just to let you know.

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        First Thing, DONT USE NAME AS VARIABLE NAME

        Try this Code:
        [code=vb]
        Dim TempStr As String
        Dim sSQL As String
        TempStr = InputBox("Pleas e insert name", "Name")
        lstRecord.Clear

        If Trim(TempStr) <> "" Then
        Set dbmyDB = OpenDatabase("E :\skol\A2 Computing\Speed y Pizza database.mdb")
        sSQL = "Select * From Staff Where FirstName Like '*" & TempStr & "*'"
        Set rsmyRS = dbmyDB.OpenReco rdset("Staff", dbOpenDynaset)
        If Not rsmyRS.EOF Then
        rsmyRS.MoveFirs t
        Do While Not rsmyRS.EOF
        lstRecord.AddIt em rsmyRS!Firstnam e & " " & rsmyRS!Lastname & vbTab & rsmyRS!StaffID
        rsmyRS.MoveNext
        Loop
        End If
        rsMyRS.Close
        End If
        [/code]



        REgards
        Veena

        Comment

        Working...