Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2005
    Posts
    7

    Unanswered: Strings in strings

    Please help. I know this is a common thing to have to deal with but I tried everything for 2 hours this afternoon and got nowhere. Hugely frustrating

    I have stored query that I run from DAO. The ctiteria looks like:-

    "first" OR "seond" in the query design windows and works when I run it from the database window.

    I replace the critria with [Level]

    and in my code I have

    qry.parameters("Level") = strParameterString

    I cannot for the life of me get "first" OR "seond" to work

    I have tried single quotes; triple double qoutes chr$(34), building the string a piece at a time. AND I get something that looks like what I want but when I

    use

    qry.execute it just does not work!! It returns nothing (my other parameter queries that use numeric values work fine)

    Any ideas before I tear out what little remains of my hair?

    TYIA

    Trevor

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    qry.parameters("Level") = "'" & strParameterString & "'"


  3. #3
    Join Date
    Jan 2005
    Posts
    7

    Still a problem

    I now have:-

    strLevelParameter = "'" & Chr$(34) & "First" & Chr$(34) & " OR " & Chr$(34) & "Second" & Chr$(34) & "'"

    The debug window tells me I have:-

    '"First" OR "Second"'

    and I still get zero results

    Any more help please?

    Trevor

  4. #4
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    I think this will then look like:
    where [Yourfield] = "''""First"" OR ""Second""''"

    which is offcourse slightly wrong...
    How about if you make 2 parameters?
    Or "simply" put the entire SQL into a string doing something like your doing but then appending the proper where?

    Regards

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    or try:

    strLevelParameter = "'First' OR 'Second'"


  6. #6
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Cyber, that will result in just the same as i explained thus will not work....

  7. #7
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    Quote Originally Posted by namliam
    Cyber, that will result in just the same as i explained thus will not work....
    Go a few steps back is what you should do: Use a SQL-statement that you KNOW is right, a full string (so no ascii- or whatever in it, just the plain string) and check out if THAT gives back any results.

    I've experienced many times that when one is not very well acquainted with the language, the problem may lie on several places. So what you need to do is make a string with 'first' or 'second' that DOES give back results. This way, you will rule out the possibility that the SQL you are trying to build is wrong to begin with, that you maybe accessing the wrong table, make spelling errors etc. It seems to me now you are focussing on the quotes when its not at all sure that is the prob. After all, it doesnt return an error, it just doesnt return results.

Posting Permissions

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