There are a handful of prepositions which can trigger either the accusative or the dative. They are the following:an, neben, in, zwischen, hinter, unter, über, vor, auf.It is often taught in schools that if motion is involved, the accusative is used, whereas if there isn't any motion, the dative is used. This is misleading, because it is direction that triggers the accusative, rather than motion. If no direction relative to the speaker is indicated, then the dative is used. "The picture is hanging on the wall"= "Das Bild hängt an der Wand". 'Wand' is a feminine word, but no direction is involved thus the dative is used, hence the 'der'. However, if you were to say "I'm hanging the picture on the wall", you would say "Ich hänge das Bild an die Wand", as the direction is indicated (towards the wall) thus the accusative is used.
See Also
German Nominative and Accusative cases + audioHow Do You Arrange German Sentences When Using Accusative or Dative?Dative case - Cases - GCSE German Revision - BBC BitesizeThe Common German Verbs Always Take the Dative CaseSee Also
Dative Case