ms-access

MS Access query returning Chinese characters - possible table corruption?


I copied and pasted a new version of the data into my MS Access table and now I'm getting weird characters in my queries. Essentially if I say:

SELECT a, b from table1

everything is fine. If I instead do

SELECT a, b from table1 group by a, b

I get really weird characters as a result. At first I got upside down L's, but now I'm getting Chinese characters. It's weird because other queries in my database use the table and get the desired output. It seems like it's only when I do a group by that I have the problems. Any suggestions? I was ready to roll it out, but now I'm getting these errors!


Solution

  • This is a bug typically met if grouping on a memo field.

    There may be several workarounds depending on your needs:

    Select 
        a, Left(b, 255) As b
    From 
        table1 
    Group By 
        a, Left(b, 255)
    
    Select 
        a, Mid(b, 1) As b
    From 
        table1 
    Group By 
        a, Mid(b, 1)
    
    Select 
        a, First(b) As firstb
    From 
        table1 
    Group By 
        a
    
    Select 
        a, DLookUp("b","table1","Id = " & [table1]![Id] & "") AS b
    From 
        table1 
    Group By 
        a, DLookUp("b","table1","Id = " & [table1]![Id] & "")