Results 1 to 3 of 3
  1. #1
    Chris Morag is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    2

    Access Update Query returns -1

    Hi, having difficulty with the following:



    IIf([ARTIST]<>" UB40",StrConv([ARTIST],3),[ARTIST]) And IIf([ARTIST]<>" UFO",StrConv([ARTIST],3),[ARTIST])

    I am trying to proper case names providing they are not one of a small number of exceptions ( 2 examples above ), which I would like to leave as is. I would be grateful for any workable solution.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    I think your statement will give a syntax error, or you should assign it to something.
    I think because you did not assign the result to anything, it is giving -1 just indicating it resolved to TRUE

    I did a test like this
    Sub may26()
    Dim artist As String
    artist = " ub40" ' "billly"
    Debug.Print IIf([artist] = " UB40" Or [artist] = " UFO", [artist], StrConv([artist], 3)) 'And IIf([artist] <> " UFO", StrConv([artist], 3), [artist])
    End Sub
    and it worked as expected giving
    Billly
    ub40

    Debug.print IIf([artist] = " UB40" Or [artist] = " UFO", [artist], StrConv([artist], 3))

    If you have more exceptions, you should do additional Or [artist] = "exception value"
    for each.

  3. #3
    Chris Morag is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    2

    Resolved

    Used the OR option and dropped the AND statement as advised and worked a treat - many thanks.


    Quote Originally Posted by orange View Post
    I think your statement will give a syntax error, or you should assign it to something.
    I think because you did not assign the result to anything, it is giving -1 just indicating it resolved to TRUE

    I did a test like this


    and it worked as expected giving



    Debug.print IIf([artist] = " UB40" Or [artist] = " UFO", [artist], StrConv([artist], 3))

    If you have more exceptions, you should do additional Or [artist] = "exception value"
    for each.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 01-13-2011, 10:15 AM
  2. Query returns duplicates
    By RobRay in forum Queries
    Replies: 3
    Last Post: 10-26-2010, 01:38 PM
  3. Replies: 2
    Last Post: 08-05-2010, 09:29 AM
  4. Aggregate Query Returns No Values
    By Xiaoding in forum Queries
    Replies: 6
    Last Post: 03-29-2010, 02:01 PM
  5. Access 2003 returns empty recordset
    By Leelers in forum Queries
    Replies: 0
    Last Post: 03-20-2009, 11:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums