Results 1 to 3 of 3

Thread: Help With SQL !!!!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    118

    Post

    Code:
    Private Sub txtHomePhone_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
    KeyAscii = 0
    Dim strSQL As String
    strSQL = "SELECT *From Customer Where (HomePhone = txtHomePhone)"


    rsOrderInfo!LastName = txtLastName

    txtLastName.SetFocus
    End If
    End Sub


    I am Trying to find the match to a home phone number that the user enters and show the results.I have never used SQL and would be thankful for help

    Thanks
    Paul

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

  2. #2
    Junior Member
    Join Date
    Jan 1999
    Location
    Seattle WA USA
    Posts
    21

    Post

    From looking at your post, I gather that the problem is that your SQL query does not work. When you put a variable in an SQL string, you have to put it inside single quotes, and to do THAT, you have to put the single qoutes inside regular quotes, otherwise VB sees the first single as meaning Remark.

    strSQL = "SELECT * From Customer Where HomePhone = " & "'"txtHomePhone"'"

    Try that (as a single line). it should work fine.

    BTW, just about everyone stumbles over this the first time, so don't feel bad.
    Dave


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

  3. #3
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    Paul,
    The select clause should be Tablename.Field
    Try:
    "SELECT Customer.* From Customer Where (HomePhone = txtHomePhone)"

    Al.

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