When working with confidence intervals for mean and proportion the margin of error (e) or level of accuracy is the distance between the sample mean or proportion and the end point of the interval.
The size of the sample can be fixed to reach the desired levels of accuracy.
Sample Size and Means
The margin of error in a confidence interval for means is:
e = z .

For example, if the confidence interval for means of a population is 50.3 ± 2.3 then e = 2.3
Remember that if σ is unknown the sample standard deviation can be used.
Example
What size of sample should be taken from a population of packets of butter, when the standard deviation of the weights of packets is 4 g, if the mean weight is to be estimated to within 0.5 g with 95% accuracy. For 95% accuracy, z = 1.96 e > z . 
0.5 > 1.96 .
√ n > 1.96 . 4 / 0.5
n > 245.9
Therefore, a sample size of 246 or greater will be needed.
Sample Size and Proportion
The margin of error in a confidence interval for proportions is:
The population proportion is rarely known and the sample proportion is used.
In opinion polls, e is referred to as the margin of error and often given as a percentage. As the proportion is not known before the opinion poll a value of 0.5 is used.
Example Radio Sport wishes to conduct an opinion poll on whether the captain of the New Zealand netball team should be replaced. The degree of confidence required for this poll is 95%. What size sample should be used to obtain the percentage to within 5% accuracy? 
For 95% accuracy, z = 1.96.
Assume p = 0.5.
.
√ n > 1.645 x √0.25 / 0.05
n > 270.6
Therefore, a sample size of 271 or greater will be needed.