To get a gba pokemon upto sun and moon you will have to go through alot of transfters.
You can transfter your 3rd gen to a 4th gen.
Then you can transfer your 4th gen to a 5th gen.
Then you can tranfter your 5th gen to a 6th gen.
After getting to a 6th gen pokemon you can move them to Pokémon Bank and then get them to sun and moon.
3rd Gen: Ruby/Sapphire/Emerald or Fire Red/Leaf Green
4th Gen: Diamond/Pearl/Platinum or Heart Gold/Soul Silver
5th Gen: Black/White or Black 2/White 2
6th Gen: X/Y or Omega Ruby/Alpha Sapphire
based off this:
https://www.reddit.com/r/PokemonHowTo/comments/2vfvoi/how_to_transfer_pokémon_from_gba_to_3ds_games/
---
Going from a gba flashcart to a retail DS pokemon tends to require a Action Replay with some custom cheat codes that make the retail cart detect the flashcart properly. You can shortcut this through the use of a pokegen program that can modify a retail DS 4th Gen save and go from there. If you don't have a retail game from each gen, you may have a problem transferring pokemon.
Once you start using retail 6th+ gen online features, you will want to stop modifying save data or you can end up getting banned.
You can find a pokegen program from projectpokemon.
https://projectpokemon.org/forums/