Looking for a passage about God forbidding that a census be taken Years ago, reading the Bible, I came across a passage where God forbade that a census be taken.  I don't remember where that was, but would like to find it again.
Looking at an online concordance, I found plenty of references where God commanded a census be taken, mostly for compiling a list of military age males (who could then be called upon to form an army).  But none forbidding a census.
I think this answers you question as far as why you're not finding a passage:

[2 Samuel 24:1] 1. A.M. 2987. B.C. 1017. An. Ex. Is. 474. And. ƒ107, Ge +10:5. again. 2 S 21:1, etc. he. That is, Satan, 1 Ch[ronicles] 21:1. ƒ63A1, Ge +14:20. This verse, when read without reference to any other part of the word of God is very difficult to understand, and has been used by those who desire to undermine the justice of God to show that he sought occasion to punish—that he incited David to sin; and when he had so incited him, gave the dreadful alternative of choosing one of three scourges by which his people were to be cut off. On the face of the passage these thoughts naturally arise, because “the Lord” is the antecedent to the pronoun “he,”—he moved David. But to those who “search the Scriptures,” this exceedingly difficult passage receives a wonderful elucidation. By referring to 1 Ch 21:1, the reader will there find that Satan was the mover, and that the Lord most righteously punished David for the display of pride he had manifested. Oh, that Christians, who sometimes have their minds harassed with doubts, would remember the promise, that what they know not now they shall know hereafter (Jn 13:7); and if no other instance of elucidation than this passage occurred to them to remove their doubts, let this be a means of stirring them up to dig deeper than ever into the inexhaustible mines of the Inspired Word. --
Smith, J. H. (1992). The new treasury of scripture knowledge: The most complete listing of cross references available anywhere- every verse, every theme, every important word (p. 360). Nashville TN: Thomas Nelson.

The Law of Moses gave the stipulations for conducting a census.  Maybe David wasn't following this.

11 The LORD said to Moses, 12 “When you take the census of the people of Israel, then each shall give a ransom for his life to the LORD when you number them, that there be no plague among them when you number them. 13 Each one who is numbered in the census shall give this: half a shekel according to the shekel of the sanctuary (the shekel is twenty gerahs), half a shekel as an offering to the LORD. 14 Everyone who is numbered in the census, from twenty years old and upward, shall give the LORD’s offering. 15 The rich shall not give more, and the poor shall not give less, than the half shekel, when you give the LORD’s offering to make atonement for your lives. 16 You shall take the atonement money from the people of Israel and shall give it for the service of the tent of meeting, that it may bring the people of Israel to remembrance before the LORD, so as to make atonement for your lives.”
(Ex. 30:11–16, ESV)