Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002
    Location
    malaysia
    Posts
    9

    Unanswered: urgent please help

    since i have 2 option button, if the user select the "ID" option button and select ID from the datacombo, it will display the particular record that the user would like to search(for this one ,it works well), but if i would like to search by surname, it cannot seaarch, y it is so?
    please have a look to my code:
    _____________________________________________
    Private Sub cmd_view_Click()
    Dim result, result1 As String
    Dim ID As Long
    Dim Surname As String
    DataGrid1.Refresh
    If opt_byID.Value = True Then


    result = "SELECT * FROM Doctor WHERE Doctor_ID LIKE '" & dcob_ID.Text & "%'"
    ado_doc_sql.RecordSource = result
    Set DataGrid1.DataSource = ado_doc_sql
    ado_doc_sql.Refresh
    End If

    If opt_sur.Value = True Then

    result1 = "SELECT * FROM Doctor WHERE Surname LIKE " & dcob_sur.Text & "%'"
    ado_doc_sql.CommandType = adCmdText
    ado_doc_sql.RecordSource = result1
    Set DataGrid1.DataSource = ado_doc_sql2
    ado_doc_sql.Refresh
    End If

    End Sub

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you're missing a singlequote

    replace
    WHERE Surname LIKE " & dcob_sur.Text & "%'"
    with
    WHERE Surname LIKE '" & dcob_sur.Text & "%'"

    the doublequotes are to delimit the strings of your query statement

    the singlequotes are part of the SELECT statement

    it's hard to distinguish them when they're smooshed up side by side like that, isn't it?

    rudy
    http://rudy.ca/

Posting Permissions

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