Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL Lookup from word (2000/2003)

    Hi everyone,

    I have attached the code I would like help with. Basically it opens a text file and uses the contents as an array. Then uses split to identify the part of each line I want to look at.

    Most of the time this works fine however out of the 33 lines currently in the text file three of them have more than one number assigned to them but I can only get one of these into the code, when the sql part is run it looks for the wrong number in the query.

    Example:

    Text file contains
    Dept A100
    Dept B120
    Dept C800
    Dept D502

    The toolbar referenced in the attached code display everything to the left of the from the above

    The SQL statement selects from a table the various variables where the number to the right of in the above text file = the number in the table.

    Toolbars current value is Dept D then the SQL will use 502 to match with.

    The problem is Dept D needs to match with 502 or 501 or 510

    My solution was to ask it to search for 5* but changing the text file from 502 to 5* doesnt work nor does 5% or 5$

    Any ideas

    Thanks
    Attached Files Attached Files
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL Lookup from word (2000/2003)

    Does it work if you change

    strDateEntry & SPM & " AND SPECEDPC = " & SPM & strRSpecCode & SPM

    to

    strDateEntry & SPM & " AND SPECEDPC Like " & SPM & strRSpecCode & SPM

    You need to use Like if you're comparing with wildcards such as * and ?. Comparing with = looks for an exact, literal match.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL Lookup from word (2000/2003)

    Hi Hans, Thank you works great.

    Sorry didn't think about it been SQL coz I am using word!

    Thanks
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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