Results 1 to 4 of 4

Thread: Help with SQL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Post

    Private Sub Command1_Click()
    Dim strSQL As String
    strSQL = "SELECT * FROM SearchByphoneNumber " & _
    "WHERE (HomePhone = """ & varHomePhone & """);"
    Me.Data1.RecordSource = strSQL
    Me.Data1.Refresh
    varHomePhone.SelStart = 0
    varHomePhone.SelLength = Len(varHomePhone.Text)

    End Sub

    When I use this code i get an error " Run-Time error '3061' "
    Too Few paremeters , expected 1

    Thanks for your help

  2. #2

    Post

    DOUBLE-QUOTES !! .. try using apostrophes, by the way it seems you are using Access-like SQL string;this is not always HEALTHY;

    strSQL = "SELECT * FROM SearchByphoneNumber " & _
    "WHERE (HomePhone = '" & varHomePhone & "')"

    ..or
    double DOUBLE-QUOTES

    strSQL = "SELECT * FROM SearchByphoneNumber " & _
    "WHERE (HomePhone = """" & varHomePhone & """");"

    Hope this works ..

    Wesam


    ------------------

  3. #3
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274

    Post

    You can also tray this syntax:

    Code:
    strSQL = "SELECT * FROM SearchByphoneNumber WHERE HomePhone = '" & varHomePhone & "'"
    Good Look!

    Ulises

    [This message has been edited by Tonatiuh (edited 08-19-1999).]

  4. #4
    New Member
    Join Date
    Feb 1999
    Location
    Palmdale, CA US
    Posts
    14

    Post

    Paul,
    Your original syntax looked ok to me (me being no expert!) Just a few (silly?) comments: 1)It appears that varHomePhone is a text box, if so try varHomePhone.text in the SQL string; 2) if varHomePhone is not a text box make sure it is a _string_ value; 3)Lastly, I have found it helpful to view the SQL string in the immediate pane while stepping through the code. This way you can verify that you're really getting what you want.

    Good luck! I've lost many hours of my life troubleshooting SQL statements too!

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