Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    49

    Unanswered: filter problem help please

    i have a form that contains a textbox (txtsearch) to filter the contents of the form.
    in event on_change of the textbox i write this code :

    Dim criteria As String
    criteria = ((NAMA_BARANG = '*" & Me("txtsearch").Text & "*') OR (KODE_BARANG = '*" & Me("txtsearch").Text & "*')) "
    DoCmd.ApplyFilter , criteria

    but there's a syntax error. what's wrong with this code?
    the purpose i write this is to filter the content of the form according to my input in
    the textbox. thank you.
    hendra gunadi

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465

    Re: filter problem help please

    Originally posted by hendra1211
    i have a form that contains a textbox (txtsearch) to filter the contents of the form.
    in event on_change of the textbox i write this code :

    Dim criteria As String
    criteria = ((NAMA_BARANG = '*" & Me("txtsearch").Text & "*') OR (KODE_BARANG = '*" & Me("txtsearch").Text & "*')) "
    DoCmd.ApplyFilter , criteria

    but there's a syntax error. what's wrong with this code?
    the purpose i write this is to filter the content of the form according to my input in
    the textbox. thank you.
    Make this change:
    Dim criteria As String
    criteria = "((NAMA_BARANG = Me![txtsearch].Text) Or (KODE_BARANG = Me![txtsearch].Text))"
    DoCmd.ApplyFilter , criteria
    Saludos
    Norberto

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Code:
    Dim criteria As String
    criteria = "[NAMA_BARANG] LIKE '*" & Me.txtsearch & "*' OR 
    [KODE_BARANG] LIKE '*" & Me.txtsearch & "*'"
    DoCmd.ApplyFilter , criteria

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •