SQL Statement

Can't seem to get this right??
trying to find records between the values in 2 text boxes on a form
any help??
Here is where I am at now
I can get the following to work

strSQL22 = "Select * from Customers Where CompanyName Like '[A-B]*'"

I want '[A-B]*' to be inputed by the user on a form that showes the results on a subform

Below does not work
strSQL22 = "Select * from Customers Where CompanyName Like ""'"[" & "Text32 " & "-" & " Text34" & "]*"'""

Thanks for your help


Comments

  • [code]sql = "SELECT * FROM Customer WHERE CompanyName LIKE '[" & Text1 & "-" & Text2 & "][color=Red]%[/color]'"[/code]
    I don't know which version of Access or SQL Server you are using.
    This works with Access 2007+ & MSDE 2000+

    [red]Good luck![/red]
    [blue]Hackman[/blue]
  • : [code]: sql = "SELECT * FROM Customer WHERE CompanyName LIKE '[" & Text1 & "-" & Text2 & "][color=Red]%[/color]'"[/code]:
    : I don't know which version of Access or SQL Server you are using.
    : This works with Access 2007+ & MSDE 2000+
    :
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]

    Thanks for the help
    kept overlooking the same thing
  • Yeah... keep overlooking ... :D

    [code]Id CompanyName
    1 ANAME
    2 BNAME
    3 CNAME
    4 ANAME2[/code]
    [code]Private Sub Command4_Click()
    Dim rst As New ADODB.Recordset

    Debug.Print Text0.Value
    Debug.Print Text2.Value

    Set rst.ActiveConnection = CurrentProject.Connection
    rst.Open "SELECT * FROM Table1 WHERE CompanyName LIKE '[" & Text0.Value & "-" & Text2.Value & "]%'"
    While Not rst.EOF
    Debug.Print rst.Fields(0) & ":" & rst.Fields(1)
    rst.MoveNext
    Wend
    End Sub[/code]
    [code]a
    a
    1:ANAME
    4:ANAME2[/code]

    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories