Results 1 to 3 of 3

Thread: is this possible?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Location
    Buffalo,NY
    Posts
    8
    I am want to use a Input box to set the WHERE clause in a SQL statement I tried using for example:
    strSQL="SELECT * from SHAPES WHERE color =Search$" but it will not recognise the value in Search$ is this possible or is there any easier way to do this .When I run in debug mode the Search$ contains the value I want but not when I add it to the sql

    Mike

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    You have the right " in the wrong spot.

    try this:

    strSQL="SELECT * from SHAPES WHERE color = '" & Search$ & "'"


    You will also need the ' before and after your variable if it is a string.

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    You can do any string formatting you like, eg sometimes you don't want a WHERE statement at all so...

    Code:
    Dim SQLStr as String
    Dim WhereStr as String
    
    If cboBox.text = "Sydney" then
        WhereStr = " where city = 'Sydney'"
    ElseIf cboBox.text = "New York" then
        WhereStr = " where city = 'New York'"
    Else
        WhereStr = ""
    End If
    
    SQLStr = "Select * from MyDB(Nolock)" & WhereStr

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